Monday, August 10, 2009

Apache2 configuration for VMWare Server 2

I've extracted this from my notes on setting up Apache2 to allow multiple IP aliases on a single IP address to point to multiple virtual machines. Mostly this post is to allow me fast access for setting up other machines.

Background info - this is setup on Ubuntu 9.04, using VMWare Server 2 and Apache2. For VMWare, I'm using bridged networking and ignoring VMWare's NAT networking capabilities (I found that it was very poorly documented to configure it easily). Basically, the host machine redirects all incoming port 80 traffic to the the Apache web server, which then gets split depending on the ip alias it is using. All modern web browsers (i.e. pretty much anything that came out in the past several years) will view the web sites correctly - old browsers do not send the alias, so will only see the first machine listed.

Make sure proxy packages are installed and enabled:
/etc/apache2/mods-available
/etc/apache2/mods-enabled (symbolic links to files in /etc/apache2/mods-available)

Packages Needed: proxy.conf, proxy_html.conf, proxy_html.load,proxy_http.load, proxy.load

Edit /etc/apache2/mods-available/proxy.conf from “Deny from all” to “Allow from all”

In /etc/apache2/sites-available/, copy “default” to “default.bak”, then edit “default” to be set up for the proxy:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName vbox1.hostname.com
ProxyPass / http://192.168.1.150/
ProxyPassReverse / http://192.168.1.150/
</virtualhost>

<VirtualHost *:80>
ServerName vbox2.
hostname.com
ProxyPass / http://192.168.1.151/
ProxyPassReverse / http://192.168.1.151/
</virtualhost>

<VirtualHost *:80>
ServerName vbox3.
hostname.com
ProxyPass / http://192.168.1.152/
ProxyPassReverse / http://192.168.1.152/
</virtualhost>
Note the slash after the virtual internal ip address – it is needed!

Restart Apache2 (/etc/init.d/apache2 restart)

Reference websites/blogs/forumns:
http://www.livingubuntu.com/?p=77
http://www.apachetutor.org/admin/reverseproxies
http://ubuntuforums.org/showthread.php?t=358687
http://serendipity.ruwenzori.net/index.php/2006/12/24/proxy-no-protocol-handler-was-valid-for-the-url
http://ubuntuforums.org/showthread.php?p=1852061#post1852061
http://httpd.apache.org/docs/2.0/vhosts/name-based.html

No comments: