DNS records for http web servers behind NAT with different external ports

1.5k views Asked by At

So basically. I have one external IP.
I am running few web servers on my internal network.
All web servers are configured in NAT with different ports (80,81,82,...)
My domain's DNS is configured on my external IP. And NAT forwards it to my first web server.

Until now when I open my domain let's say example.com it opens my first web server's page.
When I open example.com:81 it opens second server, etc..

What I am trying to achieve is some way to open my other web servers on different sub-domains without specifying port.

So I would like to have something like:
second.example.com -> example.com:81
third.example.com -> example.com:82

I am using SRV record for my TeamSpeak3 server, so my TS3 is running on port 2222 and SRV record translates my ts3.example.com to example.com:2222 and it works like a charm.

Can those sub-domains be configured by SRV records in DNS?

If it can't. Is there any other way?

Thanks

1

There are 1 answers

2
user239546 On

Since you are behind a NAT all your web-servers share the same endpoint. You will need to set up virtual hosts that resolve all requests based on domain information passed in an HTTP packet. The server that hosts these virtual hosts will then parse the incoming packets and distribute the request to the appropriate virtual host based on domain name resolution.

Apache makes this pretty easy through its implementation of name-based virtual hosts.

IIS has a solution as well as this stack overflow answer points to.

Good luck!