How to route requests through router based on domain names?

What you're asking for is pretty much impossible, because the vast, vast majority of L7 protocols have no concept of a hostname, and thus can't be proxied based on a hostname

The correct way to achieve what you want is to assign different public IP addresses, because even though you have a router in your diagram, it's actually NATting, which isn't routing at all.

So you need more IP addresses, and you can either route properly and put the public IPs on your three servers, OR, you can put the IP addresses on your router and do a 1:1 NAT (eww, especially if the NAT uses Proxy ARP to "get" the IPs)


The best way to do this is by assign a different IP by server:

  • server1 first public IP
  • server2 second public IP
  • server3 third public IP

Then assign each domain a different IP in the DNS.

If you're ISP can't provide you more IP addresses, then you can migrate elsewhere, or bring the traffic to your servers through tunnels.