An Apache2 reverse proxy can be used if administrators do not want to connect certain backend servers directly to the internet. First of all let me introduce you to the topic on a very basic level.
There are several reasons to use a Apache2 reverse proxy:
- Configure SSL certificates only on the public webserver
- Only need to allow firewall access for one server to the public
Hence this is a nice setup, I recently spent hours to find the right configuration. I wanted to use Apache2 as reverse proxy for a standalone Wildfly 10 web application. The goal was to use a subdomain for one specific Java EE application on Wildfly.
In my installation Wildfly is listening on 127.0.0.1:8090.
How to configure the Apache2 reverse proxy
The example shown below shows how to map the subdomain public.example.de on the Wildfly Webapp to the path http://localhost:8090/MyApp/:
ProxyRequests Off ProxyPreserveHost On ProxyPass / http://127.0.0.1:8090/MyApp/ ProxyPassReverse / http://public.example.de:80/MyApp/ ProxyPassReverseCookieDomain 127.0.0.1 public.example.de ProxyPassReverseCookiePath /MyApp /
Most noteworthy in the example above is the port 80 in the ProxyPassReverse rule. I found out that redirects sent from wildfly specifically address port 80. If this port is not used, redirects sent from the server are not processed correctly.
This was not mentioned in all articles I could find addressing this topic, regardless what backend server was used in the setup.
I hope this will help others as well.