You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to have a different .local domain for each installed app instead of using a different port for each one.
To do this, you can use the following approach:
Use the multicast-dns package to resolve a given domain to the device running umbrelOS.
Use Traefik/Nginx or a custom proxy implementation in node.js to route incoming traffic based on the domain to the right service.
You can also make sure that each app gets a "subdomain" of umbrel.local (e.g. homebridge.umbrel.local).
There's no such concept of a subdomain for mDNS, but you can make it work with the same convention.
I'm already using this approach on my Raspberri Pi and it works great.
The nice thing about it is that I have multiple domains on my local network, without configuring any device with a custom DNS server or anything.
To resolve any .local domain you want, you can use this code snippet:
importosfrom"os";importmdnsfrom"multicast-dns";constadditionalHostnames=newSet(["homebridge.local","umbrel.local","homebridge.umbrel.local"]);consthostnameTtl=300;constmdnsResponder=mdns();mdnsResponder.on("query",async(query)=>{constanswers=[];for(constquestionofquery.questions){if(additionalHostnames.has(question.name)&&question.type=="A"){constip=getNetworkIp();if(ip==null)continue;console.debug(`Answering to "${question.name}" mDNS query with IP "${ip}"`);answers.push({name: question.name,type: "A",ttl: hostnameTtl,data: ip});}}if(answers.length>0)mdnsResponder.respond(answers);});functiongetNetworkIp(){constifaces=os.networkInterfaces();for(constifaceofObject.values(ifaces)){for(constaliasofiface){if(alias.family==="IPv4"&&alias.address!==""&&!alias.internal)returnalias.address;}}returnnull;}
I run the mDNS responder on the device itself and not inside of a docker container, so you might need some additional configuration to make it work through docker.
I think this would significantly improve the experience of using umbrelOS, and I wanted to show how easy it is to implement the resolver.
One implementation detail that you should take into account it that trying to resolve a .local domain from inside a docker container doesn't work without intervention.
You can either append the relevant domains to the /etc/hosts file of the host machine (to make it available to all containers, with the machine's external static IP) or by using the extra_hosts key in a docker compose service. For example:
Expanding on this and making it more flexible, I think there should be a way to configure some data in each app compose file. Adding a custom url is one of them, people will use different methods for that, but after doing it, there should be a way to use that url on umbrel dashboard as well.
On this broader thing of customizing the compose we could even have env variables as well because multiple apps use those for advanced configuration. Today I can edit on the command line but all edits are lost upon updating umbrel.
Well, it can be a feature, but instead of this, why not use a reverse proxy to try and access it from the internet?
Reverse-proxy doesn't need any modifications on the docker-compose.yml file and can also work after updating apps without the need of any modification.
It would be nice to have a different
.local
domain for each installed app instead of using a different port for each one.To do this, you can use the following approach:
multicast-dns
package to resolve a given domain to the device running umbrelOS.You can also make sure that each app gets a "subdomain" of
umbrel.local
(e.g.homebridge.umbrel.local
).There's no such concept of a subdomain for mDNS, but you can make it work with the same convention.
I'm already using this approach on my Raspberri Pi and it works great.
The nice thing about it is that I have multiple domains on my local network, without configuring any device with a custom DNS server or anything.
To resolve any
.local
domain you want, you can use this code snippet:I run the mDNS responder on the device itself and not inside of a docker container, so you might need some additional configuration to make it work through docker.
I think this would significantly improve the experience of using umbrelOS, and I wanted to show how easy it is to implement the resolver.
One implementation detail that you should take into account it that trying to resolve a
.local
domain from inside a docker container doesn't work without intervention.You can either append the relevant domains to the
/etc/hosts
file of the host machine (to make it available to all containers, with the machine's external static IP) or by using theextra_hosts
key in a docker compose service. For example:The text was updated successfully, but these errors were encountered: