网站建设

nginx反向代理配置文件

daimafengzi · 9月26日 · 2023年 · 本文共1013个字 · 预计阅读4分钟6577次已读

1.在nginx/conf/nginx.conf中添加:

include conf.d/*.conf;

2.在同级目录下新建conf.d文件夹,在conf.d文件夹中新建自定义配置文件,如:cms.conf

upstream cms_server {
       server localhost:8080;
}
server
{
   listen 80;
   server_name www.aa.com;
   location / {
       proxy_redirect off;
       proxy_set_header Host $host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_pass http://cms_server;
   }
}
server
{
   listen 80;
   server_name www.bb.com;
   location / {
       proxy_redirect off;
       proxy_set_header Host $host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_pass http://cms_server;
   }
}
server
{
   listen 80;
   server_name www.cc.com;
   location / {
       proxy_redirect off;
       proxy_set_header Host $host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_pass http://cms_server;
   }
}
server
{
   listen 80;
   server_name www.dd.com;
   location / {
       proxy_redirect off;
       proxy_set_header Host $host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_pass http://cms_server;
   }
}
0 条回应
Copyright © 2022-2024 LuoWeiHua
| 耗时 0.321 秒 | 查询 57 次 | 内存 4.13 MB |