Nginx 配置文件引入:使用 include 指令加载自定义配置
Nginx 的配置文件是 nginx.conf,默认位置为 /etc/nginx/nginx.conf。在引入配置文件时,可以使用 include 指令来引入其他配置文件。
例如,可以在 nginx.conf 中使用以下指令来引入一个名为 myconfig.conf 的配置文件:
include /etc/nginx/myconfig.conf;
在 myconfig.conf 中可以写入一些自定义的配置,如:
server {
    listen 80;
    server_name 'mydomain.com';
    location / {
        proxy_pass http://localhost:8080;
    }
}
这样,在 Nginx 启动时,会先读取 nginx.conf,然后再读取 myconfig.conf 中的配置,从而实现自定义配置的效果。
原文地址: https://www.cveoy.top/t/topic/nXTN 著作权归作者所有。请勿转载和采集!