Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a domain that points to my ISP assigned IP though a CNAME (cname goes to my noip address incase my ISP decides to change the IP), I would like to route different subdomains to various IP:PORT combinations in the internal networks, but I’m not entirely sure how to accomplish this.

Currently, I have nginx acting as a reverse proxy for several different subdomains, and routing to the appropriate apache server. But I would like to also route subdomains to specific IP:port for non http communication such as RDP or VPN.

The idea is to be able to reach my services using different subdomains instead of using port forwarding to get directed to the correct IP:Port.

I have ClearOS (CentOS6) as a gateway between my network and the internet, would something with iptables work?

The end result should be something like this

  • rdp.example.com -> 192.168.1.1:3389
  • vpn.example.come -> 192.168.1.5:1194
  • www1.example.com -> nginx -> 192.168.1.1:80 (This is already setup)
  • www2.example.com -> nginx -> 192.168.1.4:80 (This is already setup)

Can anyone help?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Answer:

In general, for an arbitrary protocol running inside of TCP or UDP (because other protocols that run on top of IP don't necessarily have any concept of ports), you cannot do what you want to do, because there is no guarantee that there is any information inside the traffic "stream" to allow such routing to take place. Certain protocols, in an attempt to get around this very problem, do embed name information in their protocol (such as HTTP, with the Host header), and for those protocols there are typically proxies that will receive a request, determine the name that was presented, and then route the request to an appropriate location. Some of those proxies have been mentioned in other answers, and if those do not suffice you will no doubt receive appropriate answers if you tell us what layer 7 protocol you are attempting to proxy.

source: http://serverfault.com/questions/96469/is-there-a-way-to-forward-a-port-based-on-subdomain

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.