During nginx configuration, there will be a lot of things we don't understand. In fact, sometimes you only need to change your mind to find more ways to solve the problem. Next we will introduce the nginx configuration in detail.
# Run the user nobody Nobody; # start the process worker_processes 2; # The Global Error Log and PID document error_log logs/error. log notice; PID logs/nginx. PID; # working mode and maximum number of connections events {use epoll; worker_connections 1024;} # Set the HTTP server, use its reverse proxy function to provide Load Balancing support for HTTP {# Set the MIME type include CONF/mime. types; default_type application/octet-stream; # Set the log format log_format main '$ remote_addr-$ remote_user [$ time_local] ''" $ request "$ Status $ bytes_sent'' "$ http_r Eferer "" $ http_user_agent "'' "$ gzip_ratio "'; log_format download '$ remote_addr-$ remote_user [$ time_local] ''" $ request "$ Status $ bytes_sent'' "$ http_referer" "$ http_user_agent" ''" $ http_range "$ sent_http_content_range "'; # Set Request Buffer client_header_buffer_size 1 K; limit 4 4 K; # enable gzip module gzip on; gzip_min_length 1100; gzip_buffers 4 8 K; gzip_types text/plain; output_buffers 1 3 2 K; postpone_output 1460; # Set access log access_log logs/access. log main; client_header_timeout 3 m; client_body_timeout 3 m; send_timeout 3 m; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; # Set the Server list of Server Load balancer upstream mysvr {# The weigth parameter indicates the weight value. The higher the weight value, the higher the chance of being allocated to it # enable port 3128 server 192.168.8.1 on squid on the local machine: 3128 Weight = 5; server 192.168.8.2: 80 Weight = 1; server 192.168.8.3: 80 Weight = 6;} # Set the virtual host server {Listen 80; SERVER_NAME 192.168.8.1 www.yejr.com; charset gb2312; # Set the access log access_log logs/www.yejr.com. access. log main; # If you access/img/*,/JS/*,/CSS/* resources, you can directly obtain local documents without passing squid # if there are many such documents, this method is not recommended, because the cache effect through squid is better location ~ ^/(IMG | JS | CSS)/{root/data3/html; expires 24 h;} # enable Server Load balancer location/{proxy_pass http: // mysvr; proxy_redirect off; proxy_set_header host $ host; proxy_set_header X-real-IP $ remote_addr; proxy_set_header X-forwarded-for $ scheme; limit 10 m; Limit 128 K; Limit 90; Limit 90; proxy_read_timeout 90; proxy_buffer_size 4 K; proxy_buffers 4 32 K; Limit 64 K; Limit 64 K;} # Set the address location/nginxstatus {stub_status on; access_log on; auth_basic "nginxstatus"; auth_basic_user_file CONF/htpasswd ;}}}