Wednesday, March 23, 2011

VirtualHost Examples: Using Virtual_host and mod_proxy together

This document attempts to answer the commonly-asked questions about setting up virtual hosts.

These scenarios are those involving multiple web sites running on a single server, via name-based or IP-based virtual hosts.

The following example allows a front-end machine to proxy a virtual host through to a server running on another machine. In the example, a virtual host of the same name is configured on a machine at 192.168.111.2. The ProxyPreserveHost On directive is used so that the desired hostname is passed through, in case we are proxying multiple hostnames to a single machine
##############################################
<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass / http://192.168.111.2/
ProxyPassReverse / http://192.168.111.2/
ServerName hostname.example.com
</VirtualHost>
##############################################

No comments:

Post a Comment