I'm trying to use an Apache proxy as a front-end for a service running on a different server in my infrastructure. Let's call them proxy.example.com and service.example.com.
Proxy.example.com is listening on port 80, but service.example.com is listening on port 8888. The first thing that service.example.com does when you connect to it is to send a 302 redirect which has port 8888 included in it -- and Apache is correctly remapping the domain name but not the port in the redirect. The service on service.example.com is a third-party packaged product, so let's assume that we can't change the way it works in any way.
The relevant bit of Apache config looks like this:
ProxyPreserveHost On ProxyPass / http://service.example.com:8888/ ProxyPassReverse / http://service.example.com:8888/
Here are some (lightly anonymised) telnets to port 80. First, going direct to 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.
And going via 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.
So, how can I make Apache remap the port number as well as the domain name in the 302 redirect?