Possible Duplicate:
FTP reverse proxying based on hostname/domain

I have 3 servers which all have FTP on the same port. They are all at the same ip address behind the same router. The router cannot port forward based on the domain requested, only the port.

Currently all requests go through the router to server1.

I would like requests to s1.example.com:21 to go to server1:21
and s2.example.com:21 to go to server2:21 and etc.

Is there a simple way to do this with Apache or by some other means?


No, there's no way. The FTP protocol doesn't pass the host name, so there's no way to know what host name someone was using. You either have to use different ports, different public IP addresses, or a protocol like HTTP that has a way to pass the host name end-to-end.

  • No programs exist to redirect traffic (other than with specific protocols) based on domain name requests? – Yoshiyahu Aug 8 '12 at 5:28
  • "No" means "no". – Michael Hampton Aug 8 '12 at 5:32
  • 1
    Yes and no. 1) Yes: no programs exist to do that based on a domain name request since the domain name usually is not supplied. Just the IP, which is the same for all requests. (HTTP being an exception, that send a request which included the domain name in the request itself). 2) No: There is a way around it, but then you need different external server names (and associated IPs) which forward the request to your IP (each to a different port). 3) if you turn of NAT and get a nice public IP range then most of these kind of problems go away. That is the way IPv4 was designed. NAT is a kludge. – Hennes Aug 8 '12 at 5:33
  • 1
    (Ran out of space in the previous comment). As Micheal states. No means no. There is no way the router can port forward based on the domain requested since it does not get a domain(name) request. – Hennes Aug 8 '12 at 5:35
  • 1
    You wrote They are all at the same ip address behind the same router.. That sounds like NAT to me. NAT is a kludge to use multiple IPs on an internal site with only one public IP. It conflicts with 'proper' networking, but you either need that kludge or you need public IP address to connect to the Internet. Most people seem to select the kludge, usually as some sort of security or even because 'it is always done this way'. (It is mostly done that way since we are almost out of ip<b>v4</b> addresses). For more information look up NAT in Wikipedia. It is a too long subject to put in comments. – Hennes Aug 8 '12 at 5:39

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