我正在尝试使用Apache代理作为运行在我的基础架构中不同服务器上的服务的前端。 我们称之为proxy.example.com和service.example.com。
Proxy.example.com正在侦听端口80,但service.example.com正在侦听端口8888.service.example.com在连接到端口时所做的第一件事情是发送一个302redirect,其中包含端口8888它 – 和Apache是正确重新映射的域名,而不是redirect端口。 service.example.com上的服务是第三方打包的产品,所以让我们假设我们不能以任何方式改变它的工作方式。
Apacheconfiguration的相关位看起来像这样:
ProxyPreserveHost On ProxyPass / http://service.example.com:8888/ ProxyPassReverse / http://service.example.com:8888/
这里是一些(轻微匿名)telnet到端口80.首先,直接到service.example.com:
$ telnet service.example.com 8888 Trying xxx.xxx.xxx.xxx... Connected to service.example.com. Escape character is '^]'. GET / HTTP/1.0 Host: service.example.com HTTP/1.0 302 Found Date: Thu, 19 Jan 2012 10:38:54 GMT Content-Type: text/html Location: http://service.example.com:8888/directory/index.html Connection closed by foreign host.
并通过proxy.example.com:
$ telnet proxy.example.com 80 Trying yyy.yyy.yyy.yyy... Connected to proxy.example.com. Escape character is '^]'. GET / HTTP/1.0 Host: proxy.example.com HTTP/1.1 302 Found Date: Thu, 19 Jan 2012 10:41:08 GMT Location: http://proxy.example.com:8888/directory/index.html Via: 1.0 service.example.com Vary: Accept-Encoding Content-Length: 0 Connection: close Connection closed by foreign host.
那么,如何让Apache重新映射端口号以及302redirect中的域名呢?
我只是猜测在这里,但据我所知,ProxyPreserveHost在这里是不需要的。 我在非标准端口(> 9000)上拥有后端服务,并且只按照ProxyPass和ProxyPassRevere指令工作
您可以尝试在ProxyPreserveHost注释之后再次尝试吗?