Nginx 通过反向代理将二级域名反代至二级目录

佚名 2021-7-17 2,018 7/17

此处以将 https://二级.域名.com 反代至 https://域名.com/blog 为例

location / {
proxy_pass http://127.0.0.1:808;
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}

location /blog/ {
proxy_pass https://二级.xxx.com/; #后置斜杠不能少
proxy_set_header Host 二级.xxx.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

 

 

- THE END -

佚名

7月17日21:36

最后修改:2021年7月17日
1

共有 0 条评论