Following my blog article on optimizing your web server by using nginx and memcached, I'll now detail the first step: setting up nginx as reverse proxy on your server. This is going to be a bit tricky, and you'll be getting your hands dirty, so be warned. What does this consist in? Well basically, your website will be served by two daemons: nginx for the static content images, js, css, html... Nginx will be listening on port 80, will serve static content to visitors, and redirect any dynamic data query to Apache, running on another port -- in our case we'll be using port 8080. Nginx is a lightweight open-source http daemon http server. It is said to be extremely fast, a lot more than Apache, and I have to admit by personal experience this seems to be very true. Using nginx for serving static content dramatically improved the speed of my high traffic website. Actually, some major websites such as Wordpress. Unfortunately it doesn't seem to be compatible with nginx at the moment, it only works with Apache. So we'll run into a few problems very soon. Step 1: download and install nginx nginx requires the PCRE library. If it's not installed on your system, run the following command: make install 2. Nginx base configuration Congrats if you've made it this far! Now let's have a look at the base configuration of nginx. In my case my CPU's a quad-core, so I'll be using 4 worker processes. For more configuration keys, I suggest having a look! If you can't be arsed, here's the configuration I'll use: - user apache apache; might aswell use the same user and user group as apache! There isn't much more to configure here, so we'll start configuring Apache. But before doing so, there's one little additional configuration directive we'll add to nginx. Configuring Apache This is where it'll get dirty. If like me you run Plesk, you probably already have some vhost configuration files all over. You'll have to edit these configuration files one by one, after having modified the main conf file. It's probably already set to listen on port 80, so change it to port 8080, and add the line below. X by your actual server IP address. Save and close the file. We can't allow Apache to use port 80 as it'll be used by nginx! No need to edit the 443 references though, we'll still use Apache for all our https content. No need to worry, the fix is simple. Pick one of the vhosts configuration file. Find a vhost directive section such as this: , and add below: NameVirtualHost X. X is your server's IP address. Save the conf file and reload httpd. If your httpd reloads without warnings or error, you can proceed to the next section. Otherwise, read carefully the steps I've described above to see if you missed anything. Your website should load, even though there might be some display errors due to the port change. Major issue: when you make any change to the web configuration in Plesk, Plesk rebuilds the vhosts configuration files, which means you'll have to make these changes every time you modify the configuration! There may be some way to prevent this, if you know any, please let me know by posting a comment, I'd be very grateful. Configuring nginx as reverse proxy So far, we've only installed nginx, and made Apache listen on port 8080 instead of 80. If you stop here, everything's pretty much broken. The next step is to configure nginx in order to redirect dynamic content requests to Apache, and return them to the user properly. Start by creating a new file in the nginx configuration folder same folder as your nginx. Name this file proxy. In this file we'll define the proxy settings. We'll be using this file to configure the proxy options in each of our virtual hosts. That's not all though, there is a problem introduced by the proxification of our architecture: how is Apache going to know the real client's IP address? Since nginx will forward the http requests, Apache will be receiving the nginx IP address, in other words, your local IP your server's IP address. Begin by installing said module: service httpd restart 5. Configuring the virtual hosts Let's now see the final part of this tutorial: configuring the virtual hosts for nginx. We'll do this the clean way: for each domain hosted on your machine, create a new. Nearly all the credit goes to for writing the original Ubuntu one; the one I wrote is for CentOS, although it should work for other systems:. Well, I guess that's about it! The next article will deal with memcached, so stay tuned! Clem Hi Clement, I am writing to you for Packt Publishing, the publishers of computer related books. We are planning to publish a new book on Nginx Server and currently we are looking out for an author to write it. Your article gives me an impression that you could be a a potential author. We pay a royalty of 16% and an advance against it. If you find this proposal interesting, please get back to me at kshipras packtpub. Thanks Kshipra Singh Author Relationship Manager Packt Publishing www. I thought about configuring nginx as a reverse proxy for Apache for all the performance benefits it provides. Do you have any suggestions? Angelo C A week ago I hired ServerBuddies. They did not only install the required codecs, but they found that I need more requirements installed. After my confirmation, they installed the additional requirements for free. They always give me a nice and professional answer to my emails and they did the job very fast, very accurate and very professional. FYI, they do offer Server Management, Plesk Support, Server Maintenance, Server Monitoring, Server Troubleshooting and support at a affordable rates. They also provide Server Optimization, Plesk Support, Linux Support, cPanel Support and.