NGINX配置文件详解
|
admin
2025年12月10日 21:32
本文热度 7
|
[root@vmware-linux sbin]# ./nginx -tnginx: the configuration file /opt/nginx/conf/nginx.conf syntax is oknginx: configuration file /opt/nginx/conf/nginx.conf test is successful[root@vmware-linux sbin]# ./nginx -s reload
全局配置块
user nginx nginx;worker_processes 4;worker_cpu_affinity 0001 0010 0100 10000 ;error_log logs/error.log;pid /opt/nginx/run/nginx.pid;worker_priority 0;worker_rlimit_nofile 40000
event配置块
events {
worker_connections 10000;use epoll; accept_mutex on; multi_accept on;}
http配置块
http { include mime.types; default_type application/octet-stream;
sendfile on; tcp_nopush on; keepalive_timeout 65; gzip on; include /etc/nginx/conf.d/*.conf; server { listen 80 default_server; server_name www.abc.com; resolver 8.8.8.8 223.5.5.5 valid=30s ipv6=off; charset UTF-8; server_tokens off; access_log logs/host.access.log main; location / { root html; index index.html index.htm; 默认主页文件名 } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
两个简单server配置示例
server { listen 8000; listen somename:8080; server_name somename alias another.alias;
location / { root html; index index.html index.htm; } } server { listen 443 ssl; 监听443 端口,启用 SSL server_name localhost; ssl_certificate cert.pem; ssl_certificate_key cert.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; ssl_protocols TLSv1.2 TLSv1.3 location / { root html; index index.html index.htm; } }}
阅读原文:原文链接
该文章在 2025/12/11 9:21:15 编辑过