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>
ServerName www.myownhost.com
ServerAdmin webmaster@myownhost.com
# 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/
</VirtualHost>

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="www.myownhost.com"  proxyPort="80"
... other arguments here ...

After that, everything worked just fine.

For detailed information, see http://tomcat.apache.org/tomcat-6.0-doc/config/http.html

Diese Beiträge könnten Sie noch interessieren:

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

Hinterlasse eine Antwort

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

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>