I'm struggling with reverse proxying an app running in a Tomcat server on a closed port behind Apache. For convenience, say that I want to reverse proxy requests for 'http://mydomain/apps/my_app/' to the Tomcat app at 'http://localhost:8082/my_app/' on the remote server. All works fine with following proxy settings in an Apache vhost.conf file:
ProxyRequests off ProxyPass /apps/ http://localhost:8082/ ProxyPassReverse /apps/ http://localhost:8082/
Except for one part of the app, which generates a Java webstart file that is to be executed on the client and needs to make a connection to the Tomcat app at 'http://localhost:8082/my_app/webstart' (on the remote server).
Crux of the problem is that this connection obviously won't work, since a) the request for localhost will be interpreted relative to the client computer, and b) even if it would point to the remote server, port 8082 is closed there.
Hence, I figured out how ProxyPreserveHost can come to help, so that the host name of the original request will be propagated to the Java webstart request:
ProxyRequests off ProxyPreserveHost on ProxyPass /apps/ http://localhost:8082/ ProxyPassReverse /apps/ http://mydomain/
This works (even internal redirections in the proxied Tomcat app work by grace of the ProxyPassReverse setting)... almost. One problem remains: the URL that is used by the Java webstart file is missing the '/apps/' part, and will try to connect to 'http://mydomain/my_app/webstart', instead of 'http://mydomain/apps/my_app/webstart', wich will obviously fail since only requests starting with /apps/ are reverse proxied. Apparently, the proxied app does not 'see' the full original URL ('http://mydomain/apps/my_app/'), but only the part that's filtered out by the Proxy handling ('http://mydomain/my_app/').
Is there any Proxy setting I forgot that can make Apache pass on the path from the original URL to the proxied app?