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

I'm trying to create a setup where I have one public facing IP address that feeds to several different internal servers where each server has a unique IP in private IP space - the route is determined by the incoming domain request (similar to Apache Virtual Hosts, but for all traffic - not just HTTP). What services would I need in place to create something described above? A proxy server, load balancer, etc?

share|improve this question
    
It's not clear to me what you're asking but it sounds like you want to NAT a public ip address (routable ip address) to a private ip address (non-routable ip address). Is that the case? –  joeqwerty Sep 19 '11 at 18:10
    
@joeqwerty Yes, sorry I'm having a hard time articulating this idea into valid sentances. –  Marco Ceppi Sep 19 '11 at 18:13
    
@joeqwerty I've updated my question to better reflect what I'm looking for –  Marco Ceppi Sep 19 '11 at 18:29
    
Still not clear what you are trying to do. Are you trying to get things setup so that domain resolves to a public or private IP address, depending on which network you coming from? –  Rilindo Sep 20 '11 at 1:26

3 Answers 3

Sounds like you just need a reverse proxy like nginx/haproxy/varnish in front, distributing requests to your backend instances by domain (URL).

share|improve this answer

You have made huge changes to your question and completely dropped the EC2 aspect of it, but here's my new response:

I think you need to learn a bit more how DNS works and how virtual hosts work. DNS is used to turn a hostname into an IP address (or set of IP addresses). Once an application has an IP address to talk to DNS is no longer involved.

Virtual hosts is a feature enabled by the HTTP protocol (version 1.1 and up). When contacting the IP address, the client passes in the hostname they want to make the request of. Your proxy server would need to be set up to understand HTTP and map to different back end servers.

Most other IP protocols do not have this feature so there is no way to do what you ask. E.g., there is no hostname involved after the DNS lookup when you ssh to a server.

That said, it sounds like you have a particular problem to solve. Rather than assume IP address routing is the answer, how about asking about what you are trying to do at a higher level and see what folks come up with? I'd recommend starting that in a new question.


I leave below my original responses to what appeared to be your original set of questions...

What you are trying to do is not clear from the wording of your question. Here are some answers to possible questions:

It is not possible to "conserve IP addresses" on Amazon EC2. Each instance uses one public IP address whether or not you allow it to be accessed from the Internet.

EC2 already has private DNS names for the private IP addresses, but they are no more useful to use than the private IP addresses themselves.

You are welcome to run your own DNS server inside or outside EC2. There are some DNS serving software packages that support code plugins where you dynamically determine the resulting IP address based on algorithms.

If you resolve an EC2 instance public DNS name from an EC2 host, Amazon will return the private IP address so your networking will be faster and cheaper. For more information on this feature, see this article I wrote:

Using Elastic IP to Identify Internal Instances on Amazon EC2
http://alestic.com/2009/06/ec2-elastic-ip-internal

share|improve this answer
    
Thanks, I've updated my question to better reflect what I'm trying to do. I assumed this is what Amazon EC2 does - but it appears I was wrong. –  Marco Ceppi Sep 19 '11 at 18:29

Your application protocol(s) need to able to signal, as part of the incoming connection, which backend server they want to use. HTTP does this (as you identify) using "name-based virtual hosting", where the Host header in the request is used by the webserver to determine which name was used in the request, and then make a decision as to where to send the request. Some other existing protocols are also capable of this to some degree (FTP, of all things, has an equivalent mechanism), but it must be done at the application layer -- you can't deal with this at the IP layer, there isn't enough information.

Quite honestly, if this is only for a few different domains, and you're working with a protocol that doesn't support name-based signalling, you'll be far better off just using multiple IP addresses and binding each name to it's own address. This is annoying and painful on EC2, because of the one-elastic-IP-per-instance limitation (and you really don't want to be using the instance IP for public-facing services; that'll just make your users sad pandas down the line).

share|improve this answer

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.