28Oct/090
Apache virtual host proxy
I had to move some virtual hosts from one server (server "A") to another server (server "B") without changing DNS records for affected domains yesterday. This can be done easily with Apache's mod_proxy module. An example configuration of the server "A" is shown below:
-
<virtualhost *:*>
-
ProxyPreserveHost On
-
ProxyPass / http://192.168.111.2/
-
ProxyPassReverse / http://192.168.111.2/
-
ServerName hostname.example.com
-
</virtualhost>
The ProxyPreserveHost directive preserves the Host HTTP header, which is passed through to the proxied server configured by the ProxyPass directive. Virtual host's configuration on server "B" is the same, which was placed originally on server "A", e.g.:
-
<virtualhost *:*>
-
ServerName hostname.example.com
-
DocumentRoot /var/www/html/hostname.example.com
-
</virtualhost>
References:
