0

I want to map subdomain to local IPs on my machine to achieve a IP for each of my virtual machines.

I know I can setup a DNS on my own machine but that will only resolve the domain on my own machine.

subdomain.domain.com -> Public IP -> Internal IP 1
subdomain2.domain.com -> Public IP -> Internal IP 2
subdomain2.domain.com -> Public IP -> Internal IP 3

is there anything that might achieve the same goal?

Note: I don't want only port 80 I want something like a NAT or Reverse proxy for all TCP payloads.

Thank you for reading.

Arty
  • 3

1 Answers1

2

You can't.

The "trick" that is normally used to simulate what you ask for (with a reverse proxy) works (only) with HTTP(S) because the protocol includes the requested DNS host name in each request. That is what allows a HTTP reverse proxy running on the primary IP-address to identify that a request is for a specific site and forward it to correct back-end server.

Most other protocols do not include the DNS hostname the client used to connect to a server. The client locally resolves whatever DNS hostname is used to an IP-address and attempts to make a connection to that IP-address. The original hostname information is "lost" and the only information carried in the (initial) request are the resolved IP-address and port number.

For every protocol that isn't natively hostname aware there won't be any way to correctly map the request to a specific back-end server.

Also see: How do I make protocol foo hostname-aware?

Do the SSH or FTP protocols tell the server to which domain I am trying to connect?


The solution is to use IPv6 on all your servers and map each of your DNS hostnames to the IPv6 address of the correct back-end server.

HBruijn
  • 84,206
  • 24
  • 145
  • 224