Tomcat behind Apache 2 reverse proxy

Today, I wanted to set up a Tomcat engine that runs on some 80xx port so that it looks like a usual web server running on port 80. I had to fiddle with the settings for some time and maybe, you have got the same steps to do, so this is what I did:

Insert this virtual host declaration in /etc/apache2/vhosts.d/myown_vhost.conf:

<VirtualHost *:80>
# don't lose time with IP address lookups
HostnameLookups Off
# needed for named virtual hosts
UseCanonicalName Off
ProxyPass / http://localhost:80xx/
ProxyPassReverse / http://localhost:80xx/

But this was not enough. Some application inside Tomcat calls request.getServerName() and still gets „localhost“. So, inside Tomcat, I had to edit conf/server.xml and modify the connector declaration:

<Connector port="8088"  address="localhost"  proxyName=""  proxyPort="80"
... other arguments here ...

After that, everything worked just fine.

For detailed information, see

Diese Beiträge könnten Sie noch interessieren:

Matthias, ich will mehr solche Tipps und Tricks per E-Mail bekommen !

Schreib einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *