nginx.conf configuration file explanation

# run user
#user somebody;
 
#Start the process, usually set to be equal to the number of CPUs
worker_processes 1;
 
#global error log
error_log D:/Tools/nginx-1.10.1/logs/error.log;
error_log D:/Tools/nginx-1.10.1/logs/notice.log notice;
error_log D:/Tools/nginx-1.10.1/logs/info.log info;
 
#PID file, record the process ID of the currently started nginx
pid    D:/Tools/nginx-1.10.1/logs/nginx.pid;
 
#Working mode and connection limit
events {
  worker_connections 1024; #Maximum number of concurrent connections for a single background worker process
}
 
#Set up the http server and use its reverse proxy function to provide load balancing support
http {
  #Set the mime type (mail support type), the type is defined by the mime.types file
  include    D:/Tools/nginx-1.10.1/conf/mime.types;
  default_type application/octet-stream;
   
  #setup log
  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  D:/Tools/nginx-1.10.1/logs/access.log main;
  rewrite_log   on;
   
  The #sendfile directive specifies whether nginx calls the sendfile function (zero copy mode) to output the file. For ordinary applications,
  #Must be set to on. If it is used for applications such as downloading and other applications with heavy disk IO load, it can be set to off to balance the processing speed of disk and network I/O and reduce the uptime of the system.
  sendfile    on;
  #tcp_nopush   on;
 
  #Connection timeout
  keepalive_timeout 120;
  tcp_nodelay    on;
   
  #gzip compression switch
  #gzip on;
  
  #Set the actual server list
  upstream zp_server1{
    server 127.0.0.1:8089;
  }
 
  #HTTPServer
  server {
    #Listen on port 80, port 80 is a well-known port number, used for the HTTP protocol
    listen    80;
     
    #Define access using www.xx.com
    server_name www.helloworld.com;
     
    #front page
    index index.html
     
    #Point to the directory of the webapp
    root D:\01_Workspace\Project\github\zp\SpringNotes\spring-security\spring-shiro\src\main\webapp;
     
    #Encoding format
    charset utf-8;
     
    #Proxy configuration parameters
    proxy_connect_timeout 180;
    proxy_send_timeout 180;
    proxy_read_timeout 180;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarder-For $remote_addr;
 
    #The path of the reverse proxy (bound with upstream), the path of the mapping is set after the location
    location / {
      proxy_pass http://zp_server1;
    }
 
    #Static files, nginx handles it by itself
    location ~ ^/(images|javascript|js|css|flash|media|static)/ {
      root D:\01_Workspace\Project\github\zp\SpringNotes\spring-security\spring-shiro\src\main\webapp\views;
      # Expiration 30 days, static files are not updated very much, the expiration can be set larger, and if it is updated frequently, it can be set smaller.
      expires 30d;
    }
   
    #Set the address for viewing Nginx status
    location /NginxStatus {
      stub_status      on;
      access_log      on;
      auth_basic      "NginxStatus";
      auth_basic_user_file conf/htpasswd;
    }
   
    #Disable access to .htxxx files
    location ~ /\.ht {
      deny all;
    }
     
    #Error handling page (optional configuration)
    #error_page  404       /404.html;
    #error_page  500 502 503 504 /50x.html;
    #location = /50x.html {
    #  root  html;
    #}
  }
}

 

Article source: http://www.jb51.net/article/94483.htm

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326221599&siteId=291194637