Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

  • ->
  • vpn.example.come ->
  • -> nginx -> (This is already setup)
  • -> nginx -> (This is already setup)

Can anyone help?

share|improve this question
up vote 0 down vote accepted


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.


share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .