nginx配置文件详解
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
#核心core配置部分
ser nginx; #指定nginx所属用户
worker_processes auto; #工具人进程数量 处理用户请求的进程
error_log /var/log/nginx/error.log; #nginx错误日志及位置
pid /run/nginx.pid; pid文件
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf; #额外模块的配置文件(一般不用)
events区域
events {
worker_connections 1024; #工具人进程可以处理多少个连接
}
#http区域
http {
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; #提高nginx性能
tcp_nopush on; #提高nginx性能
tcp_nodelay on; #提高nginx性能
keepalive_timeout 65; #长连接超时时间
types_hash_max_size 4096;
include /etc/nginx/mime.types; #incloud文件包含 把另一个文件内容粘贴到这里
default_type application/octet-stream; #nginx指定默认的媒体类型
# 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; #把conf.d nginx子配置文件包含include进来
server {
listen 80; #监听的端口
listen [::]:80; #ipv6监听的端口
server_name _; #网站域名
root /usr/share/nginx/html; #指定站点目录
# Load configuration files for the default server block.
#include /etc/nginx/default.d/*.conf;
#用来匹配用户请求中的uri
location / {
index index.html: #默认的首页文件
}
error_page 404 /404.html; error_page 指定404错误的时候 访问404.html
location = /404.html {
}
error_page 500 502 503 504 /50x.html; 报错5xx 访问/50x.html 显示错误提示
location = /50x.html {
}
}
# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2;
# listen [::]:443 ssl http2;
# 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;
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
}