Tuesday, November 8, 2011

Configuring nginx as proxy for apache in ubuntu

Sponsored Links
Install apache2 and nginx services.

In this setup we configured apache to run on port 81 and nginx on port 80

nginx configuration file is given below :


root@host ~ # vi /etc/nginx/nginx.conf
user www-data;


worker_processes  1;
error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;
events {
    worker_connections  1024;
    # multi_accept on;
}
http {
    include       /etc/nginx/mime.types;
    access_log  /var/log/nginx/access.log;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;
    gzip  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
server {
        listen ip_address:80;
        server_name domain.com www.domain.com;
        location / {
        proxy_pass http://ip_address:81/;
        proxy_redirect http://ip_address:81/ /;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_connect_timeout 150;
        proxy_send_timeout 100;
        proxy_read_timeout 100;
        proxy_buffers 4 32k;
        client_max_body_size 8m;
        client_body_buffer_size 128k;
                }
        location ~* ^.+\.(jpg|js|jpeg|png|ico|gif|txt|js|css|swf|zip|rar|avi|exe|mpg|mp3|wav|mpeg|asf|wmv)$ {
        root document_root_of_domain;
                }
        }
}
Sponsored Links

No comments:

Post a Comment

Be nice. That's all.