Map Subdomains to Docker Containers with Synology
3 min read

Map Subdomains to Docker Containers with Synology

Map Subdomains to Docker Containers with Synology

The other day I got fed up with having to insert diskstation.local:12345 to point towards an installed service on my NAS. I also thought that my SO has difficulties remembering all the ports (I do too) and cleaning up the browser cache doesn't help either. So, I thought:

Wouldn't it be nicer if instead of disksation.local:32400 I could just type plex.laurii.lan?

Yes! Yes, it would! :)

So I started my quest to make things happen.

Use case

My se case is the following:

As a local user, I want to have nice names for the services I've installed.

This breaks down into:

  • local user - I only want the names to be accessible on my LAN. I don't want access from the outside
  • nice names - I want to type nice, easy to remember names.
  • services I've installed - I have a bunch of low-usage services on my NAS, some installed as packages (like Plex), others installed as Docker containers.

Since I don't have WAN/VPN requirements, the closest solutios I could find were:

  • a reverse proxy tutorial which involves manual editing of nginx config files
  • a dns server solution which implied declaring a reverse subdomain for each service

My solution

My solution is somewhat a hybrid of the two:

  • I have a local DNS server
  • I also have reverse proxy

DNS

For the DNS server, I've installed Synology's DNS Server package and enabled the DNS resolution as per most tutorials:

DNS resolution

I then created a master zone named laurii.lan, with the DNS server pointing to the IP of the Synology machine:

DNS master zone

I then created:

  • a laurii.lan A record pointing also to the synology machine and
  • a *.laurii.lan CNAME with laurii.lan as canonical name (type * in the Name field)

DNS master zone records

Once these are done, the DNS part is concluded. If you set up the DNS on your device (PC, phone etc.), typing something.laurii.lan will actually point back to your device:

nslookup

Reverse proxy

Synology DSM provides you with the possibility to define reverse proxies via Control panel - Application portal. We can define a reverse proxy for plex:

Reverse proxy

Once saved, you can access the plex server as plex.laurii.lan. Nice!

Example

Closing up

Once we defined all servers, the Reverse proxy tab of the Application portal can look like this:

Reverse proxies

The idea is that now you can map any applications which expose ports to subdomains (eventually with their own defined ports).

Now, if you have a decent network, you already have a capable router and IMHO it's better if you keep everything concentrated on the router. However, I thought that keeping the configuration local to my Synology box is worth the effort. Now when I install a new service, I only have to define a new reverse proxy to a subdomain.

HTH,