nginx virtual host

From WebHostingNeeds.com
Jump to: navigation, search

http://wiki.nginx.org/VirtualHostExample

To add virtual host, inside

http {


Add a

server {
}

entry. For example

server {
        listen       67.228.104.121:80;
        server_name  img3.bizhat.com;
	access_log  /var/log/nginx/img3.bizhat.com.log;
	root /home/bizhat/img3.bizhat.com;
}


Nginx as Proxy

Following is entry used for labs.buyscripts.in. It is a ruby application running on port 67.228.104.121:3000

upstream mongrel {
server 67.228.104.121:3000;
}

server {
        listen       67.228.104.121:80;

        server_name  labs.buyscripts.in;

        access_log  /var/log/nginx/labs.buyscripts.in.log;


        # Main location
        location / {
            proxy_pass http://mongrel;
            proxy_redirect     off;

            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

            client_max_body_size       10m;
            client_body_buffer_size    128k;

            proxy_connect_timeout      90;
            proxy_send_timeout         90;
            proxy_read_timeout         90;

            proxy_buffer_size          4k;
            proxy_buffers              4 32k;
            proxy_busy_buffers_size    64k;
            proxy_temp_file_write_size 64k;
        }

    }



nginx