Nginx 配置文件
主配置只保留全局设置,站点配置通过 include 引入,便于测试、回滚和自动化发布。
目录组织
/etc/nginx/
├── nginx.conf
├── conf.d/
│ └── example.com.conf
└── snippets/
├── proxy.conf
└── security.conf主配置引用
http {
include /etc/nginx/mime.types;
include /etc/nginx/conf.d/*.conf;
}站点文件 /etc/nginx/conf.d/example.com.conf:
server {
listen 80;
server_name example.com;
root /var/www/example.com;
include /etc/nginx/snippets/security.conf;
}安全发布
sudo nginx -t && sudo nginx -s reload