How to map sub domain to internal IP adress

1

I'd like to reach some internal services like the web client of my NAS (Synology DSM) through dedicated sub domains like https://nas.example.com.

The services are fully running and accessible via internal IPs like https://192.168.0.200:5001.

I obviously own the domain example.com and have an Apache server up & running.

There are basically 2 reason why I'd like to achieve the above:

  • The sub domain nas.example.com is easier to remember than 192.168.0.200:5001
  • I'd like to use my existing HTTPS certificates for nas.example.com which I can't with internal IP addresses

I've already played around with Apache's mod_rewrite but had no success at all. Unfortunately I can't tell if this scenario is even possible with mod_rewrite or if I just didn't configure it correct.

Some notes:

  • The services should not be accessible from outside but only from within my LAN.
  • Ideally, they should also be accessible via the sub domains when connected with the network from outside via SSH tunnels. Therefore a dedicated DNS server like dnsmasq is not what I'm looking for since that would only treat requests from within the LAN (I guess...).

suamikim

Posted 2018-02-19T07:26:23.590

Reputation: 135

Answers

1

It's easier to do with nginx, but apache can handle this too, using mod_proxy

You should set up a VirtualServer for domain nas.mysite.com and enable Reverse Proxy for this virtual server:

ProxyPass "/"  "http://192.168.0.200:5001"
ProxyPassReverse "/"  "http://192.168.0.200:5001"

WhiteWind

Posted 2018-02-19T07:26:23.590

Reputation: 150

1

Don't bother setting up a reverse proxy when:

The services should not be accessible from outside but only from within my LAN.

Simply create a DNS record that points nas.example.com to your IP-address

nas.example.com. IN A 192.168.0.200

Non-internet routable ip-addresses from the 192.168.0.0/16 subnet will only work within your own LAN.

Then configure the DSM web interface to run on port 80, the default port for HTTP and you won't need to use a port number like 5000 in the URL anymore.

HBruijn

Posted 2018-02-19T07:26:23.590

Reputation: 1 024

Yeah, I missed that point – WhiteWind – 2018-02-19T09:55:39.923

FYI: If I could I would have also accepted your answer since it showed an easy alternative I wouldn't have thought of before but I chose the one with reverse proxy since it opens up more options for me. Thanks either way! – suamikim – 2018-02-20T07:33:04.283