With one IP and one Port only (i.e. Port 80), you can only run one Server public.
Take one of these Servers as standard public server. To access the other (hidden) Server, you must either use a different domain name name or a directory name beyond the first Server (and domain). If you use different (public) domain names (what i recommend and i only show example for this case), you have to define two virtualhosts in the public server, one for the public server itself and one for the hidden server. You can show the websites of the hidden server using a "reverse proxy" in the matching virtualhost declaration.
Server1 is domain1.com and domain2.com, but
Server2 "should" serve for domain2.com
Server1 has Public IP and must also have a local IP in the LAN (you can assign either more than one IP to one network card or use two network cards in Server1, one for the WAN and one for the LAN). Server2 is part of the LAN does only have a local IP in the LAN.
If you use a router instead (where both Server1 and Server2 are connected to the router), the Public IP is assigned to the router, Server1 and Server2 have local LAN IPs and the router must be configured to "forward" all requests from Port 80 to Server1.
In httpd.conf of Server1 you have to define 2 vitualhost domain1.com, domain2.com. For domain1.com apply DocumentRoot and so on, for domain2.com you create an reverse proxy which yields to the local LAN IP of Server2:
(Basic example where xxx.xxx.xxx.xxx is the Public IP of Server1 or the local LAN IP of Server1 if it is connected to a router, lan.lan.lan.lan is the Local LAN IP of Server2)
- Code: Select all
NameVirtualHost xxx.xxx.xxx.xxx :80
ProxyPass / http://lan.lan.lan.lan
ProxyPassReverse / http://lan.lan.lan.lan
On Server2 you simply configure an Apache Server listening on lan.lan.lan.lan with ServerName lan.lan.lan.lan
Of course you may apply an internal ServerName for Server2 (like local.server2 or similar) and apply this to the hosts file of Server1 and Server2 with Local IP lan.lan.lan.lan and then use this ServerName in all instances instead of the local IP lan.lan.lan.lan. This is not quite necessary, but some people dont like naked IPs. Neither the local IP nor the ServerName of Server2 is "visible" to the Internet, for any user in the WWW it will look like as Server1 serves domain2.com as well as domain1.com (what actually is the case, but Server1 shows the contents of Server2 for domain2.com).
For mor information read the Apache documentation about Reverse Proxys (the above example is the most basic reverse proxy as possible).