Wednesday, August 17, 2011

nginx configuration

To enhance the performance and security of my web server , few days back i decided to use Reverse proxy theory. My idea was to put a a lightweight web server in front of my apache web sever to serve all the static contents by that lightweight web server, and dynamic content by main backend apache web server. In my study, I found that Apache itself can implement reverse-proxy, but i decided to go for lightweight web server. In my learning process i got some good feedback for lighttpd , but nginx is more popular (Based on stuffs i got by googling).

I decided to go with nginx for testing and deployment.

After installing nginx, Initially i done following configuration in default ngnix sitesconfiguration file, in my case it is (/etc/nginx/sites-available/default)

server {

listen 80;


accesslog /var/log/nginx/access.log;

location / {



location /images {

root /data/web/images;

autoindex on;



I my example my apache server is running on port 8080. Here reverse proxy concept is used to to forward all home page accessing(, to port 8080 on localhost (in our case apache is running on 8080). All access to will served directly by nginx.