I'm running a tomcat
webserver on port 8080
behind a apache2
, and want to redirect some ports.
For testing, I'm trying to redirect to an invalid location, as follows:
<VirtualHost *:80>
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto "http"
ProxyPass / http://127.0.0.1/test80
ProxyPassReverse / http://127.0.0.1/test80
</VirtualHost>
<VirtualHost *:8080>
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto "http"
ProxyPass / http://127.0.0.1/test8080
ProxyPassReverse / http://127.0.0.1/test8080
</VirtualHost>
Result:
The :80
redirect works as expected.
BUT accessing :8080
shows the tomcat manager starting page, instead of the redirect. Why?
Somehow it seems as if the apache2
could not take control of that port?
Best Answer
I guess there is no
Listen 8080
option in your apache config files. Just adding the port to a VirtualHost is not enough.check one of these files (based on your distribution) for Listen options and add one for port 8080:
more info here: https://www.tecmint.com/change-apache-port-in-linux/
But as mentioned in the comments, you cannot have two services listening on the same port. You have to change the tomcat listening port for this to work.