Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
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, 192.168.1.3), then serve the data it gets from 192.168.1.3. It would do this for each site. I'm not sure, but Apache should be able to do something similar to this. –  Thomas W. 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 W. 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 W. Sep 19 '13 at 23:22
add comment

2 Answers

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
  </Location>
</VirtualHost>

<VirtualHost *:80>
  ServerName fooa.com

  ProxyPreserveHost on
  ProxyPass / http://server2/
  ProxyPassReverse / http://server2/
</VirtualHost>

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

  ProxyPreserveHost on
  ProxyPass / http://server3/
  ProxyPassReverse / http://server3/
</VirtualHost>

Is perfectly what I wanted along with mod_proxy

share|improve this answer
add comment

Note

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>

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

    # Other directives here
</VirtualHost>

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.

share|improve this answer
    
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 W. 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. –  George Kourouleas 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. –  George Kourouleas Sep 20 '13 at 10:45
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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