Virtual Hosts
To get this working add the following line to the /etc/apache2/httpd.conf file and then restart the web service.
NameVirtualHost *:80
Restarting the web service can be done in the Terminal using:
sudo serveradmin stop web
sudo serveradmin start web
Now you can add virtual hosts through the Server app.
Multiple web servers within a LAN accessed from one WAN address.
Set up: The following assumes that you have 3 servers with correctly working DNS and apache services. The 10.10.10.x subnet is used for the examples, change them to whatever configuration you are using.
Set up a NAT rule on your router/modem to point port 80 through to, for example, 10.10.10.200 (or the address of the primary apache service that will redirect domains to their correct machine):
- first.domain.com = 10.10.10.200
- second.domain.com = 10.10.10.201
- third.domain.com = 10.10.10.202
- ZONE - domain.com
- machine record server1.domain.com. points to 10.10.10.200
- machine record server2.domain.com. points to 10.10.10.201
- machine record server3.domain.com. points to 10.10.10.202
- alias record first.domain.com. points to server1.domain.com.
- alias record second.domain.com. points to server2.domain.com.
- alias record third.domain.com point to server2.domain.com.
Once this is done you can start adding the .conf files to the /etc/apache2/sites folder to do the redirecting.
You can name the files as you like so long as they have the .conf extension.
1st File I will call 0000_any_80_first.domain.com.conf it needs the following in it to do the redirect to the correct machine:
<VirtualHost *:80> ServerName first.domain.com ProxyPreserveHost on ProxyPass / http://server1.domain.com/ ProxyPassReverse / http://server1.domain.com/ </VirtualHost>
<VirtualHost *:80> ServerName second.domain.com ProxyPreserveHost on ProxyPass / http://server2.domain.com/ ProxyPassReverse / http://server2.domain.com/ </VirtualHost>
<VirtualHost *:80> ServerName third.domain.com ProxyPreserveHost on ProxyPass / http://server3.domain.com/ ProxyPassReverse / http://server3.domain.com/ </VirtualHost>
sudo serveradmin stop web
sudo serveradmin start web
[crarko adds: I haven't tested this one. This might also be possible to do in Lion client, but the hint as is applies to Lion Server.]

