nginx 可以实现两层代理么?

2016-03-17 10:42:12 +08:00
 hayao650
我想实现这样的功能,客户端访问我的 80 端口,然后 nginx 转发到 xxx 端口,如果 xxx 端口是 404 的话,就转发到 yyy 端口,请问可以实现这个功能么?
5421 次点击
所在节点    NGINX
11 条回复
lhbc
2016-03-17 10:47:10 +08:00
可以。
Andy1999
2016-03-17 10:50:37 +08:00
后端存活配置?
realpg
2016-03-17 10:55:11 +08:00
保密网数据上公网,搞过 6 层 nginx 反代……
公网阿里云华北服务器,替换域名反代到公网北京联通服务器,再通过 VPN 反代到堡垒机,堡垒机反代到去公网内容旁路审计服务器,再反代到指挥中心服务器,最后反代到内网源服务器……
hayao650
2016-03-17 11:09:57 +08:00
@realpg 你说的这个是不同服务器,我是想在一个 nginx 上实现
hayao650
2016-03-17 11:10:18 +08:00
@lhbc 求详解
hayao650
2016-03-17 11:10:26 +08:00
@Andy1999 不太懂,求详解
Andy1999
2016-03-17 11:36:24 +08:00
defunct9
2016-03-17 11:42:44 +08:00
error_page 404 /example.com.404.html;

location = /example.com.404.html {
root html;
allow all;
index example.com.404.html
rewrite ^ $scheme://www.someothersite.com$request_uri permanent;
}
lhbc
2016-03-17 13:11:03 +08:00
livia313
2016-03-17 14:39:53 +08:00
可以
system
2016-03-17 14:45:39 +08:00
@realpg 你这就只是个反代而已。他要的是本机双层代理

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/264122

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX