# For more information on configuration, see:# * Official English Documentation: http://nginx.org/en/docs/# * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx;# 运行用户,默认是nginx worker_processes auto;# nginx进程数,一般设置为和cpu核数一样 error_log /var/log/nginx/error.log;# 全局错误日志路径 pid /run/nginx.pid;# 进程pid路径 # Load dynamic modules. See /usr/share/nginx/README.dynamic.# 负载动态模块include /usr/share/nginx/modules/*.conf; events {# 工作模式与连接数上限 worker_connections 1024; # 单个进程的最大连接数} http {# 设置http服务器 log_format main ‘$http_host $server_addr $remote_addr [$time_local] "$request" $status $request_body $body_bytes_sent "$http_referer" "$http_user_agent" $request_time $upstream_response_time‘; # 设置日志的格式 access_log /var/log/nginx/access.log main; # 访问日志的路径 sendfile on; # 开启高效传输模式 tcp_nopush on; # 激活tcp_nopush参数可以允许把http response header和文件的开始放在一个文件里发布,作用是减少网络报文段的数量 tcp_nodelay on; # 激活tcp_nodelay,内核会等待将更多的字节组成一个数据包,从而提高I/O性能 keepalive_timeout 65; # 长连接超时时间,单位是秒 types_hash_max_size 2048; # 为了快速处理静态数据集,例如服务器名称, 映射指令的值,MIME类型,请求头字符串的名称,nginx使用哈希表 include /etc/nginx/mime.types; # 文件扩展名与类型映射表 default_type application/octet-stream; # 默认文件类型 # Load modular configuration files from the /etc/nginx/conf.d directory. # 加载模块化配置文件 # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; server { # 基于域名的虚拟主机 listen 80 default_server; # 监听端口 listen [::]:80 default_server; server_name _; # 域名 root /usr/share/nginx/html; # 站点根目录,即网站程序存放目录 # Load configuration files for the default server block. # 默认服务器块的加载配置文件 include /etc/nginx/default.d/*.conf; location / { # 对“/”启用反向代理 } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } # Settings for a TLS enabled server.## server {# listen 443 ssl http2 default_server;# listen [::]:443 ssl http2 default_server;# server_name _;# root /usr/share/nginx/html;## ssl_certificate "/etc/pki/nginx/server.crt";# ssl_certificate_key "/etc/pki/nginx/private/server.key";# ssl_session_cache shared:SSL:1m;# ssl_session_timeout 10m;# ssl_ciphers HIGH:!aNULL:!MD5;# ssl_prefer_server_ciphers on;## # Load configuration files for the default server block.# include /etc/nginx/default.d/*.conf;## location / {# }## error_page 404 /404.html;# location = /40x.html {# }## error_page 500 502 503 504 /50x.html;# location = /50x.html {# }# } }
原文地址:https://www.cnblogs.com/yjlch1016/p/9313463.html
时间: 2024-11-10 22:22:30