Home Assistant remote access with Duck DNS and NGINX

I run Home Assistant on a Nabu Casa Green. To access it remotely I followed these steps.

Table of Contents

1. Create Duck DNS

  1. Log in or create an account with Duck DNS.
  2. Create a sub-domain of your choice.
  3. Copy the token you’ve been provided.

2. Install Duck DNS add-on in HA

  1. Install the add-on.
  2. Configuration YAML:
domains:
  - sub-domain.duckdns.org
token: <paste-your-duck-dns-token-here>
aliases: []
lets_encrypt:
  accept_terms: true
  algo: secp384r1
  certfile: fullchain.pem
  keyfile: privkey.pem
seconds: 300
  1. Check the log and make sure it returns success.

3. Install NGINX add-on in HA

  1. Install the add-on.
  2. Configuration YAML:
domain: sub-domain.duckdns.org
hsts: max-age=31536000; includeSubDomains
certfile: fullchain.pem
keyfile: privkey.pem
cloudflare: false
customize:
  active: true
  default: nginx_proxy_default*.conf
  servers: nginx_proxy/*.conf
  1. Same procedure here. Make sure the logs show success.

4. Edit HA configaration.yml

  1. I use Studio Code Server to edit the HA system file configuration.yaml.
  2. Add the following:
http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 172.30.33.0/24 #nginx subnet, leave as is

5. Change your HA public url

  1. Visit /config/network or navigate to Settings -> System -> Network
  2. Change the Home Assistant URL to your domain name used in the Duck DNS config.

6. Add port forward in router

  • Go to your router settings and add a port forward to the local IP of your HA installation and add port 8126. Use the TCP protocol.

7. Try connecting to your domain

  • It should all be set-up and you can now connect to your hardware remotely via sub-domain.duckdns.org:8126.