I’ve struggled with this for some time and am definitely doing something wrong.
I have Apache server and a JBoss server on the same machine. I’d like to redirect traffic for mydomain.example to JBoss localhost:8080/example. The DNS is currently setup for mydomain.example and it will go straight to port 80 when entered into the browser.
My question is how do I redirect to a different port when a certain domain name comes to Apache (in this case, mydomain.example)?
<VirtualHost ip.addr.is.here>
ProxyPreserveHost On
ProxyRequests Off
ServerName mydomain.example
ProxyPass http://mydomain.example http://localhost:8080/example
ProxyPassReverse http://mydomain.example http://localhost:8080/example
</VirtualHost>
After implementing some suggestions:
-
Still not forwarding to port 8080
<VirtualHost *:80> ProxyPreserveHost On ProxyRequests Off ServerName mydomain.example ServerAlias www.mydomain.example ProxyPass http://mydomain.example http://localhost:8080/example ProxyPassReverse http://mydomain.example http://localhost:8080/example </VirtualHost>
You should leave out the domain
http://example.comin ProxyPass and ProxyPassReverse and leave it as/. Additionally, you need to leave the/at the end ofexample/to where it is redirecting. Also, I had some trouble withhttp://example.comvs.http://www.example.com– only the www worked until I made the ServerName http://www.example.com, and the ServerAlias example.com. Give the following a go.After you make these changes, add the needed modules and restart apache