After a great deal of searching the net for answers I have pieced together what is needed to do a couple of things I have wanted to do for some time now. The first is to have virtual hosts working nicely on 10.7 Lion Server. The second and related item is to have multiple web servers within a LAN accessible from one WAN address.
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):
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:
2nd File is called 0000_any_80_second.domain.com.conf containing:
3rd File is called 0000_any_80_third.domain.com.conf containing:
Restart the web service with the Terminal command:
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.]
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.]




I did all this on a new mid-2010 Mac mini Server (with an external MacBook Air SuperDrive), with OS X Server 10.6.5 (re)installed on the upper drive (*disk1*) and OS X client 10.6.5 (and Fusion, many other apps, etc.) installed on the lower drive (*disk0*): i.e., with the computer used mainly as a client desktop rather than a server; so, virtualizing the server OS might be the most convenient solution, while - if desired - also being able to natively boot into the server (at least as an experiment).