user nginx; worker_processes 2; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 10240; } http { include /etc/nginx/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 /var/log/nginx/access.log main; # 文件快速传输 sendfile on; #tcp_nopush on; server_tokens off; keepalive_timeout 65; gzip on; #不压缩临界值,大于4K的才压缩 gzip_min_length 4k; gzip_buffers 4 16k; #用了反向代理的话,末端通信是HTTP/1.0,默认是HTTP/1.1 #gzip_http_version 1.0; #压缩级别,1-10,数字越大压缩的越好,时间也越长 gzip_comp_level 6; #进行压缩的文件类型, gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; gzip_vary off; gzip_disable "MSIE [1-6]\."; # 过滤代理自身IP real_ip_header proxy_protocol; set_real_ip_from 172.16.0.0/12; set_real_ip_from 10.100.0.1; real_ip_recursive on; include /etc/nginx/conf.d/*.conf; }