I currently have a Ubuntu web server with Apache setup and running wonderfully, I want to do two things, I want to setup two more boxes which would be on the same WAN address but of course have separate local addresses.

So say I have www.example.com as the main server I also want test.example.com on a different box and fun.example.com on a third.

How would I accomplish this?

  • You would need to have one server listening to all three and reverse proxy to the local network servers. In nginx, which is not apache, we would have this by having one "master server" for nginx, but multiple local servers, the master server would be internet facing, and would listen to all domain names, and then would pass the requests to the server on the local IP (say,, then serve the data it gets from It would do this for each site. I'm not sure, but Apache should be able to do something similar to this. – Thomas Ward Sep 19 '13 at 23:14
  • To confirm my interpretation of your question, is your network topology like this, but you want each local network IP to have an individual site on it with its own server? INTERNET <==> Router/Gateway (gets public IP) <==> Local Network IPs – Thomas Ward Sep 19 '13 at 23:15
  • Yes that is the basic topology – Randy Kupel Sep 19 '13 at 23:21
  • Okay, that's what I thought, the answer provided by George below is not going to work for what you need. The only way is to set up one "master server" that can act as a proxy / middleman server, which would then, based on what's being requested, proxy/relay data between the Internet and a local server. I'm not sure how to do that in Apache, but we've at least narrowed down what's needed for people to answer (i.e. basic network topology and what the setup is from the Internet to your system). Note the domains/subdomains need DNS entries to your public IP address for your router regardless. – Thomas Ward Sep 19 '13 at 23:22

From the Link Provided by George Kourouleas

Apache Reverse Proxy

Is what I was looking for

NameVirtualHost *:80

<VirtualHost *:80>
  ServerName foo.com

  DocumentRoot /srv/www/default

  <Location "/">
    Order Deny, Allow
    Deny from all
    Allow from all

<VirtualHost *:80>
  ServerName fooa.com

  ProxyPreserveHost on
  ProxyPass / http://server2/
  ProxyPassReverse / http://server2/

<VirtualHost *:80>
  ServerName foob.com
  ServerAlias fooc.com

  ProxyPreserveHost on
  ProxyPass / http://server3/
  ProxyPassReverse / http://server3/

Is perfectly what I wanted along with mod_proxy



Creating virtual host configurations on your Apache server does not magically cause DNS entries to be created for those host names. You must have the names in DNS, resolving to your IP address, or nobody else will be able to see your web site. You can put entries in your hosts file for local testing, but that will work only from the machine with those hosts entries.

# Ensure that Apache listens on port 80
Listen 80
<VirtualHost *:80>
    DocumentRoot /www/example1
    ServerName www.example.com

    # Other directives here

<VirtualHost *:80>
    DocumentRoot /www/example2
    ServerName www.example.org

    # Other directives here

The asterisks match all addresses, so the main server serves no requests. Due to the fact that the virtual host with ServerName www.example.com is first in the configuration file, it has the highest priority and can be seen as the default or primary server. That means that if a request is received that does not match one of the specified ServerName directives, it will be served by this first VirtualHost.

Answer from http://httpd.apache.org

Kind regards.

  • I'm not sure this answers their question. I'm guessing they have one public IP and multiple local net IPs, if that's the case, DNS won't help them, nor would virtual hosts. – Thomas Ward Sep 19 '13 at 23:15
  • Thomas is correct, the way this is setup would be hosting them all on the same Server which is not what I want to do – Randy Kupel Sep 19 '13 at 23:28
  • 1
    In the case that solution does not work, I would suggest to give mod_proxy a try. It is a very stable and good module. Unfortunately, I cannot commend on the above comments. I still believe that Virtual Hosting would be a good solution though. If you are certain that virtual hosts will not work, please provide some extra information. Last but not least, give this a good read. – Paul Sep 19 '13 at 23:28
  • Now that link you gave me is what I am looking for, Thank you! – Randy Kupel Sep 19 '13 at 23:37
  • I am glad I helped. Good luck. – Paul Sep 20 '13 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.