As Daniel said above, there is many ways to achieve this… And a lot depends on your installation method and network setup…
Myself I am running Home Assistant Container, so no add-ons, and I have my own registered domain name, let’s say EXAMPLE.com
. I also do not currently expose HA or anything else to the Internet.
I wanted a wildcard certificate (*.EXAMPLE.com
) so that I could use it for more than just HA. With Lets-encrypt that means using the DNS challenge method to generate the certificate. Details here; Home-Automation/Lets Encrypt at main · Fraddles/Home-Automation · GitHub
Once I had my certificate I updated my HA config to use it. I applied HTTPs to the HA webserver directly without using any reverse proxy. Some info and working docker-compose.yaml here; Home-Automation/Home-Assistant at main · Fraddles/Home-Automation · GitHub
The certificate will only be accepted by your browser/device if the name you are using is one of the names (or IPs) embedded in the certificate… In my case I have a wildcard cert that will match any* URL ending in EXAMPLE.com
. For example home-assistant.EXAMPLE.com
, jellyfin.EXAMPLE.com
, etc…
I can access HA using any of the following;
https://IP-ADDRESS:8123
https://home-assistant.local:8123
https://home-assistant.INTERNALDOMAIN.home:8123
https://home-assistant.EXAMPLE.com:8123
The first thee of these will allow me to access Home Assistant, but will give me a certificate error, as none of those names are in the certificate. I need to use the last one for the certificate error to go away.
My local DNS provider (my router) does not, by default, know anything about EXAMPLE.com
, so queries for that domain are forwarded to my upstream (Internet) DNS… The upstream DNS is also not helpful here as I have not configured records with my internal IPs (or any at all actually).
How to resolve this depends on your network setup… This is where Adguard, PiHole, etc comes in. Myself I have a Ubiquiti USG and I can SSH into it and create a static DNS entry for any name I want with the following command;
set system static-host-mapping host-name home-assistant.EXAMPLE.com inet 192.168.0.xx
Which results in any local DNS requests matching the host-name will be resolved to the specified internal IP. I could also add a record to my external DNS (with my external IP), open port 8123 on my router and access it remotely using the same URL.
Hopefully some of the above is useful to you…
Cheers.