user www-data; worker_processes auto; pid /run/nginx.pid; # user nginx nginx; nginx user and group # worker_processes; work processes number, always 2 times to cpu # pid; pid=process IDentifier # pid /run/nginx.pid; the pid storage path events { worker_connections 768; # multi_accept on; # 每个worker_process工作进程的最大连接数量 # 根据硬件调整,和前面worker_process工作进程配合起来用,尽量大,但是别把cpu跑到100%就行 # 每个进程允许的最多连接数,理论上每台nginx服务器的最大连接数为worker_processes*worker_connections } # 设定http服务器,利用它的反向代理功能提供负载均衡支持 http { ## # Basic Settings基础配置 ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; # sendfile on; 指定 nginx 是否调用sendfile 函数(zero copy 方式)来输出文件,对于普通应用,必须设为on # 如果用来进行下载等应用磁盘IO重负载应用,可设置为off,以平衡磁盘与网络IO处理速度,降低系统uptime # tcp_nopush on; 允许或禁止使用socket的TCP_CORK的选项,此选项仅在使用sendfile的时候使用 include /etc/nginx/mime.types; default_type application/octet-stream; # include /etc/nginx/mime.types; 设定mime类型,类型由mime.type文件定义 ## # SSL SettingsSSL配置 ## ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE ssl_prefer_server_ciphers on; ## # Logging Settings日志配置 ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; # access_log 用了log_format指令设置了日志格式之后,需要用access_log指令指定日志文件的存放路径 # error_log 错误日志存放路径 ## # cache缓存配置 ## ##proxy_cache_path /usr/local/cache inactive=60m keys_zone=test:10m max_size=1g; ##proxy_ignore_headers Cache-Control Expires; #proxy_cache_path 设置内存缓存空间大小为10MB,60分钟没有被访问的内容自动清除,硬盘缓存空间大小为1GB ## # Gzip Settings压缩包配置 ## gzip on; gzip_disable "msie6"; # gzip_vary on; # gzip_proxied any; # gzip_comp_level 6; # gzip_buffers 16 8k; # gzip_http_version 1.1; # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; ## # Virtual Host Configs虚拟host配置 ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; } #mail { # # See sample authentication script at: # # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript # # # auth_http localhost/auth.php; # # pop3_capabilities "TOP" "USER"; # # imap_capabilities "IMAP4rev1" "UIDPLUS"; # # server { # listen localhost:110; # protocol pop3; # proxy on; # } # # server { # listen localhost:143; # protocol imap; # proxy on; # } #}
更多配置的详解https://blog.csdn.net/tjcyjd/article/details/50695922
Uncharacteristic front-end development intern.