Multiple web-sites behind a single IP

In order to install multiple web-sites with the same IP, the web-sites have to be identified by DNS name. Secondly, one will want to have a different installation of apache for each of the individual web-sites.

I configured a set-up where I have a single forwarding proxy, and all different vm’s with individual web-services. With Apache 2.2, the config is as follows.

The firewall has a public ip, and is forwarding all requests on port 80 and port 443 to the private proxy. The proxy server has a private ip (e.g. 10.0.1.10) and is forwarding all requests to individual servers. I will present 2, but you can repeat as much as you want. The private servers are on 10.0.1.21 and up….

Activate your proxy includes by creating a symbolic link:
su root
cd /etc/apache2/mods-enabled
ln -s ../mods-available/proxy.load proxy.load
ln -s ../mods-available/proxy_http.load proxy_http.load

Edit /etc/apache2/httpd.conf and add following sections:
UseCanonicalName On
NameVirtualHost 10.0.1.10

<virtualhost 10.0.1.10>
ServerName webmail.mydomain.com
ServerAlias www.webmail.mydomain.com
ProxyPreserveHost On
ProxyPass / http://10.0.1.21/
ProxyPassReverse / http://10.0.1.21/
</virtualhost>

<virtualhost 10.0.1.10>
ServerName clientzone.mydomain.com
ServerAlias www.clientzone.mydomain.com
ProxyPreserveHost On
ProxyPass / http://10.0.1.22/
ProxyPassReverse / http://10.0.1.22/
</virtualhost>

… that is it… simple once you know but it took me a lot of time to find it out.

Leave a Reply