Reverse Proxy for TCP (RDP, VPN, etc) and HTTP

3

1

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?

Greg Somers

Posted 2012-10-07T17:32:43.610

Reputation: 41

Answers

1

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: https://serverfault.com/questions/96469/is-there-a-way-to-forward-a-port-based-on-subdomain

Greg Somers

Posted 2012-10-07T17:32:43.610

Reputation: 41