[TOC] ## nginx.conf 配置 ``` #自动按 cpu 数配置 #user nobady; pid /run/nginx.pid; worker_processes 8; worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000; #打开的最多文件描述符数目 最好与ulimit -n的值保持一致 worker_rlimit_nofile 65535; events { ## 处理大批量句柄而作了改进的poll use epoll; ## 每个进程允许的最多连接数 worker_connections 65535; accept_mutex off; multi_accept off; } http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 60 50; send_timeout 10s; types_hash_max_size 2048; # 客户端请求头部的缓冲区大小 client_header_buffer_size 4k; client_max_body_size 8m; include /etc/nginx/mime.types; default_type application/octet-stream; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; gzip_disable "msie6"; gzip_min_length 1024; gzip_vary on; gzip_comp_level 2; gzip_buffers 32 4k; gunzip_static on; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; ## # Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; } ```