Wednesday 31 August 2011

Apache reverse proxy of virtual hosts

Here you have a simple example on how to create a vhost for a reverse proxied site:

NameVirtualHost *:80
<VirtualHost *:80>
    ServerName blue.domain.com
    ProxyRequests off
    ProxyPass / http://blue.internal.domain.com/
    ProxyPassReverse / http://blue.internal.domain.com/
</VirtualHost> 
<VirtualHost *:80>
    ServerName red.domain.com
    ProxyRequests off
    ProxyPass / http://red.internal.domain.com/
    ProxyPassReverse / http://red.internal.domain.com/
</VirtualHost>
This is also useful if you have a tomcat or anything else running on a different port and you want to serve everything on the same port:

<VirtualHost *:80>
    ServerName tom.domain.com
    ProxyRequests off
    ProxyPass /myapp http://localhost:8080/myapp
    ProxyPassReverse /myapp http://localhost:8080/myapp
</VirtualHost>

Possibly Related Posts

No comments:

Post a Comment