Nginx simple configuration

Recommended for you: Get network issues from WhatsUp Gold. Not end users.


user  nobody;
worker_processes  1;

error_log  /usr/local/nginx/logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /usr/local/nginx/logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

 

    #Open the gzip compression

    gzip  on;


    #Maximum file size, can be used to restrict the upload file size
    client_max_body_size 100m;

 
    #Will not bring www domain to WWW domain name
    server {

        #Listen on port 80
        listen 80;

        #Domain name
        server_name ***.com;
         rewrite ^/(.*) permanent;
    }
 
    server {
        listen 80;
        server_name www.***.com;

 

        #Set the site root directory
        set $htdocs /project/na2;#Here the definition of HtDocs
        root $htdocs;

 

        #Set the encoding format
        charset utf-8;
 

        #Setting up website home page, page loading speed
        location =/ {
            index index.html index.jsp;
        }

 

        #All requests to the localhost:8088

        location / {
          index index.jsp;
          proxy_pass ;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header REMOTE-HOST $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

 

        #Cache the image of 30 days

        location ~ .*.(gif|jpg|jpeg|png|bmp|swf|css|js|html)$ {
                expires 30d;
        }

 

        #Access forbidden/WEB-INF
        location ~^/(WEB-INF)/{
           deny all;
        }
    }

}

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Harriet at February 12, 2014 - 7:46 AM