TD540
Posts: 17
Joined: Sat Sep 07, 2019 5:57 am

Can I give web services on Pi their own local domains?

Mon Apr 27, 2020 5:08 pm

Lets say I have two services running: Pi-Hole on port 80 and some other web service running on port 8080...

Can I somehow give them custom domains, so that any user on my local network can just surf to “pi-service1.local” to see the Pi-hole web admin, and “pi-service2.local” to see the other web service, whichever it may be?

Instead of now “raspberrypi.local:80” and “raspberrypi.local:8080”?

I think this will be easier for users on my network to save passwords.

(Pi-hole is my DHCP server)

epoch1970
Posts: 5022
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Can I give web services on Pi their own local domains?

Tue Apr 28, 2020 7:06 pm

What you’re looking for isn’t domains.
.local is mDNS, mDNS handles distributed name resolution to IP addresses via multicast.
mDNS usually comes with DNS-SD, which is a protocol that allows publishing services. 2 nice things there: you can publish as many services as you want on a single machine, and you can advertise the port the service uses.
On Raspbian these services are provided by Avahi-daemon, which is preinstalled.

Examples of service declarations with avahi:
https://holyarmy.org/2008/01/advertisin ... hibonjour/

And now the bad news. Web browsers used to feature a “Bonjour Tab” that would listen on the local network and collect all _http._tcp services and provide links you could click. Very useful and friendly.
Some time (like years) ago this was deemed a security threat to web browsers and today none offer a Bonjour Tab. You’ll need to install a browser plugin on each machine, assuming you can find one.

With normal DNS you can give 2 (or a 100) IP addresses to one machine, a name associated to each address. However that does not handle the port part if you absolutely need to use 8080 instead of the standard 80.
You’d need to handle that in a firewall rule..

A better option might be to have an http server listening on one address, many DNS names associated with that address, and redirect rules in the http server, so that the query hits some path or some other based on the hostname part of the url. Could handle port mapping if you need that. Will only work if the protocol is http.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

TD540
Posts: 17
Joined: Sat Sep 07, 2019 5:57 am

Re: Can I give web services on Pi their own local domains?

Fri May 01, 2020 9:03 pm

I guess what I'm looking for is kind of like Pi-hole

On my local network, I can just browse to http://pi.hole and get the pi hole web admin tool. I'd like to do the same for other services, like for example SABnzbd which runs its http server on port 8080...

Something like SABnzbd.local or .whatever ;)

Eventually I'd like to run some of my own web apps that I want to make available via a custom chosen local domain, like a little Node.js podcast server or a my own CalDAV server or something.

epoch1970
Posts: 5022
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Can I give web services on Pi their own local domains?

Fri May 01, 2020 9:20 pm

Again, name resolution is one thing.
Telling machines to use this protocol or that port number is something else.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Beginners”