nginx 分离配置文件 conf.d和default.conf


1. 在 nginx.conf 文件中引用 conf.d 下的所有配置文件

#在http配置节的末尾添加配置引用
http {
    ...

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}

2. 在 conf.d 中添加 default.conf 配置文件

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
    
    #代理配置
    location /business {
        proxy_pass  http://business.app.com;
    }
    
    #代理配置
    location /user {
        proxy_pass  http://user.app.com;
    }
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM