[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Many domains, many servers, 1 public IP.

Posted on 2009-02-13
Medium Priority
Last Modified: 2012-06-21
Here's my inventory:

1 - Public IP (
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, 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!
Question by:techport13
  • 3
  • 2
LVL 15

Expert Comment

ID: 23638499
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 Comment

ID: 23638528
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.
LVL 15

Expert Comment

ID: 23640615
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.

    DocumentRoot /srv/www/htdocs
    ServerName domain1.com
    DocumentRoot /srv/www/htdocs/domain1
    ServerName domain2.com
    DocumentRoot /srv/www/htdocs/domain2
    ServerName domain3.com
    DocumentRoot /srv/www/htdocs/domain3

Open in new window


Author Comment

ID: 23641450
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.
LVL 15

Accepted Solution

gplana earned 2000 total points
ID: 23642013
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).
2. Just use different ports as you suggested.

The second option would be easier.


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

this article is a guided solution for most of the common server issues in server hardware tasks we are facing in our routine job works. the topics in the following article covered are, 1) dell hardware raidlevel (Perc) 2) adding HDD 3) how t…
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month20 days, 7 hours left to enroll

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question