You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Eric Jain <Er...@isb-sib.ch> on 2005/12/01 20:03:36 UTC

Setting up virtual hosts behind a reverse proxy

I have a Tomcat (5.5.12) server that is hidden behind Apache. On the Apache 
server, several virtual hosts are defined.

<VirtualHost xxx.xxx.xxx.xxx>
   ServerName xxxxxxxx.xxxxxxx.xx
   ProxyPass / http://localhost:8080/
   ProxyPassReverse / http://localhost:8080/
</VirtualHost>

Now I'd like to map some of these virtual hosts to virtual hosts on the 
Tomcat server.

Unfortunately this doesn't quite work as Tomcat is unaware of the original 
hostname that was requested (even though this information remains present 
in a X-Forwarded-Host header value).

Any suggestions?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Setting up virtual hosts behind a reverse proxy

Posted by Eric Jain <Er...@isb-sib.ch>.
Eric Jain wrote:
> I have a Tomcat (5.5.12) server that is hidden behind Apache. On the 
> Apache server, several virtual hosts are defined.
> 
> <VirtualHost xxx.xxx.xxx.xxx>
>   ServerName xxxxxxxx.xxxxxxx.xx
>   ProxyPass / http://localhost:8080/
>   ProxyPassReverse / http://localhost:8080/
> </VirtualHost>
> 
> Now I'd like to map some of these virtual hosts to virtual hosts on the 
> Tomcat server.
> 
> Unfortunately this doesn't quite work as Tomcat is unaware of the 
> original hostname that was requested (even though this information 
> remains present in a X-Forwarded-Host header value).

The solution turned out to be quite simple:

<VirtualHost xxx.xxx.xxx.xxx>
   ServerName xxxxxxxx.xxxxxxx.xx
   ProxyPass / http://xxxxxxxx.xxxxxxx.xx:8080/
   ProxyPassReverse / http://xxxxxxxx.xxxxxxx.xx:8080/
</VirtualHost>

i.e. forward requests to xxxxxxxx.xxxxxxx.xx:8080 rather than localhost:8080.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org