# Summarize the content of the nginx. conf file.
# Running user
User www-data;
# Start the process. Generally, it is set to be equal to the number of CPUs
Worker_processes 1;
# Global Error Log
Error_log/var/log/nginx/error. log;
# Process files
Pid/var/run/nginx. PID;
# The maximum number of file descriptors opened by an nginx process. The theoretical value should be that the maximum number of opened files (system value ulimit-N) is the same as the number of nginx processes, but the allocation requests of nginx are uneven, therefore, we recommend that you keep the value consistent with that of ulimit-n. Worker_rlimit_nofile 65535; # working mode and maximum number of connections
Events {
Use epoll; # epoll is a method of multiplexing io (I/O multiplexing), but it is only used for Linux and later kernels, which can greatly improve nginx performance.
Worker_connections 1024; # maximum number of concurrent connections of a single backend Worker Process
# Multi_accept on;
}
# Set the HTTP server and use its reverse proxy function to provide Load Balancing support
HTTP {
# Set the MIME type, which is defined by the mime. type file.
Include/etc/nginx/mime. types;
Default_type application/octet-stream;
# Set the log format
Access_log/var/log/nginx/access. log;
# The sendfile command specifies whether nginx calls the sendfile function (zero copy mode) to output files. For common applications,
# It must be set to on. If it is used for downloading and other application disk I/O heavy load applications, you can set it to off to balance the disk and network I/O processing speed and reduce the system uptime.
Sendfile on;
# Tcp_nopush on;
# Connection timeout
# Keepalive_timeout 0;
Keepalive_timeout 65;
Tcp_nodelay on;
# Enable gzip Compression
Gzip on;
Gzip_disable "MSIE [1-6] \. (?!. * Sv1 )";
# Set Request Buffer
Client_header_buffer_size 1 K;
Large_client_header_buffers 4 4 K;
Include/etc/nginx/CONF. d/*. conf;
Include/etc/nginx/sites-enabled /*;
# Set the Server list of Server Load balancer
Upstream mysvr {
# The weigth parameter indicates the weight. A higher weight indicates a higher probability of being assigned.
# Enable port 3128 for squid on the local machine
Server 192.168.1.11: 3128 Weight = 5;
Server 192.168.1.12: 80 Weight = 1;
Server 192.168.1.13: 80 Weight = 6;
}
# Configure Server {# listener port listen 80; # multiple domain names. Separate SERVER_NAME www.ha97.com ha97.com with spaces; index index.html index.htm index. PHP; root/data/www/ha97; location ~. *. (PhP | PhP5 )? $ {Fastcgi_pass 127.0.0.1: 9000; fastcgi_index index. php; Include FastCGI. conf ;}# set the image cache time location ~. *. (GIF | JPG | JPEG | PNG | BMP | SWF) $ {expires 10d;} # JS and CSS cache time settings location ~. *. (JS | CSS )? $ {Expires 1 h ;} # Set the log format to log_format access' $ remote_addr-$ remote_user [$ time_local] "$ request" ''$ Status $ response" $ http_referer "'' "$ http_user_agent" $ http_x_forwarded_for '; # define the access log access_log Ar/logstores/ha97access for this VM. log Access; # enable reverse proxy location/{proxy_pass http: // 127.0.0.1: 88; proxy_redirect off; proxy_set_header X-real-IP $ remote_addr; # The backend web server can use X-forwarded-for to obtain the user's real ipproxy_set_he Ader X-forwarded-for $ proxy_add_x_forwarded_for; # The following are some reverse proxy configurations, which are optional. Proxy_set_header host $ host; client_max_body_size 10 m; # maximum number of single-file bytes allowed for client requests client_body_buffer_size 128 K; # maximum number of bytes cached by the buffer proxy client request, proxy_connect_timeout 90; # nginx and backend server connection timeout (proxy connection timeout) proxy_send_timeout 90; # backend server data return time (proxy sending timeout) proxy_read_timeout 90; # after successful connection, response time of the backend server (proxy receiving timeout) proxy_buffer_size 4 K; # Set the buffer size proxy_buffers 4 32 K for the proxy server (nginx) to save user header information; # proxy_buffers buffer, set proxy_busy_buffers_size 64 K on average for Web pages below 32 K; # buffer under high load Size (proxy_buffers * 2) proxy_temp_file_write_size 64 K; # sets the cache folder size. If it is greater than this value, it will be uploaded from the upstream server} # sets the address location/nginxstatus {stub_status on for viewing nginx status; access_log on; auth_basic "nginxstatus"; auth_basic_user_file confpasswd; # the content of the htpasswd file can be generated using the htpasswd tool provided by Apache .} # Reverse proxy configuration for local dynamic/static separation # All JSP pages are handled by tomcat or resin. Location ~. (JSP | jspx | Do )? $ {Proxy_set_header host $ host; proxy_set_header X-real-IP $ remote_addr; proxy_set_header X-forwarded-for $ scheme; proxy_pass http: // 127.0.0.1: 8080 ;} # All static files are directly read by nginx without passing through tomcat or resinlocation ~. *. (HTM | HTML | GIF | JPG | JPEG | PNG | BMP | SWF | IOC | RAR | zip | TXT | FLV | mid | Doc | PPT | PDF | XLS | MP3 | WMA) $ {expires 15d;} location ~. *. (JS | CSS )? $ {Expires 1 h ;}}}