Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have created 2 VM's on a single machine for 2 webservers. One server will be running the IIS service and the second server will be running Apache services.

How do I configure my server/router to make 2 different domains work on different servers with a single static ip address.

share|improve this question
add comment

1 Answer 1

If you want to host your web server on the standard HTTP (80) or HTTPS (443) ports, I think you cannot have two different machines answer depending solely on the domain name.

The thing is, when you access some site, you are not accessing it via a domain name - you are just using DNS to map that domain name to an IP. The reason you can host multiple sites on the same IP is the Host header - see section 14.23 Host of RFC 2616:

How this works is the following. Let's say we have two domains a.example.com and b.example.com pointing to the same IP, say 10.0.0.10. Client, usually using some Web browser, asks DNS for the IP of a.example.com. DNS replies back with 10.0.0.10. Client then sends something like:

Host: a.example.com

When your web server receives this, it can then determine that you actually want a.example.com and not b.example.com (or possibly other virtual hosts on that web server).

In your example, however, you don't have one server - you have two servers. Router would need to route to one of them based solely on the IP - the Host header is processed on the application layer while routing is done on the IP layer (see TCP/IP model). While some routers do some decisions based on the application layer, I don't think any can go that deep into the packet to examine the HTTP headers and route based on that result.

What you can do is:

  • Make one of the two VMs the default and then proxy through to the other one
  • Make a third VM that will proxy to both current VMs

See e.g. this for more information about virtual hosts:

See e.g. these about setting up a reverse proxy:

Here is the reference documentation for the modules that can be used to make reverse proxy:

Hope this helps.

share|improve this answer
add 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.