We help IT Professionals succeed at work.

Many domains, many servers, 1 public IP.

techport13
techport13 asked
on
Medium Priority
468 Views
Last Modified: 2012-06-21
Here's my inventory:

1 - Public IP (12.34.56.78)
1 - Consumer Router
4 - domain names (domain1.com, domain2, domain3.com, domain4.com)
4 - Server machines (1, 2, 3, 4) behind the router
1 - Spare centOS machine.

I would like to find a way to to point the name servers for each of my domains to 12.34.56.78, and then somehow direct all traffic for domain1.com to machine1, domain2.com to machine2, etc etc.

I know that I can do this very easily with multiple public IPs.  I can also do this by not duplicating ports on any of the machines.  But I don't really want to go that route.

Any thoughts?  Perhaps I could expose the centOS box as a routing machine and do some kind of translation and routing with that.  I don't know - I haven't the foggiest idea where to start.  I'm also not asking for specific information, but rather specific research topics and places to look to find the information required.

Thanks in advance!
Comment
Watch Question

CERTIFIED EXPERT

Commented:
Do you really need one server for each domain ? There is an easy way for attaching 4 different domains to a single server using apache virtual hosts.

Please take a look here: http://httpd.apache.org/docs/1.3/vhosts/

Author

Commented:
I'm not running multiple webservers.  If I were, virtual hosts would be perfect for what I was looking for.  Unfortunately, I basically need a way to say "Any traffic that requests domain1, domain2, or domain3 needs to be routed internally as follows:"

domain1 => computer1 => prod app listening on port 4500
domain2 => computer2 => test app listening on port 4500
domain3 => computer3 => dev app listening on port 4500

I could run them on different ports, but it's much easier to say to someone go to domain1.com for production, domain2.com for test, etc instead of domain.com:1234 for prod, domain.com:2345 for test, etc etc.
CERTIFIED EXPERT

Commented:
Sorry for the delay of my answer.

you don't need to run multiple physical webservers. You should just configure the httpd.conf file for this purpose on the same machine. Then, what you would be saying is: all traffic that comes with "domain1.com" redirecto to localhost/dir1, all traffic that comes with "domain2.com" redirect to localhost/dir2, etc... So you don't need multple servers neither to use multple ports (although you can use if you want).

On the other hand: I don't think you can instruct your router to redirect domain1 to an internal IP because this translation is accomplished by DNS, which is  a top layer on the OSI layers (router is on layer 3, and he only handles IPs and ports).

I put an example of you to configure httpd.conf file with the 3 domains on the same machine, but any domain to a different folder. You should change the IP by the ip of your host.

Hope it helps. Regards.



<VirtualHost 146.219.196.123>
    ServerName 146.219.196.231 
    DocumentRoot /srv/www/htdocs
</VirtualHost>
 
<VirtualHost 146.219.196.123>
    ServerName domain1.com
    DocumentRoot /srv/www/htdocs/domain1
</VirtualHost>
 
<VirtualHost 146.219.196.123>
    ServerName domain2.com
    DocumentRoot /srv/www/htdocs/domain2
</VirtualHost>
 
<VirtualHost 146.219.196.123>
    ServerName domain3.com
    DocumentRoot /srv/www/htdocs/domain3
</VirtualHost>

Open in new window

Author

Commented:
Thanks for your reply.  I am not running web servers.  I have multiple instances of applications that listen for connections on the same port running on different machines.

I think I will end up using different ports since I've not been able to find a way to redirect all traffic to a separete machine by domain.
CERTIFIED EXPERT
Commented:
Right in that case you have two options:

1. Instruct your application for analysing the site asked (after wht word GET in the GET petition).
or
2. Just use different ports as you suggested.

The second option would be easier.

Regards.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.