[SOLVED] Home assistant reverse proxy setup with Caddy 2

I’m new to home automation and have just set up Home assistant as a container on an Intel NUC. The home assistant instance is working great locally and I can control the devices I have added without issue.

My current project is to get access externally from my network by using a reverse proxy and I have setup caddy for this purpose.

All the port forwarding for 80, 443, and the caddy side appears to be functional as I have no problem using https://portainer.mydomain.com/ to access my portainer container from outside my network.

I am having difficulty however getting Home Assistant to work.

My caddyfile contains:

`portainer.mydomain.com` {
        reverse_proxy 192.168.1.156:9000
}

`hass.mydomain.com` {
        reverse_proxy 192.168.1.156:8123
}

I have added internal and external URLs:

External: https://hass.mydomain.com/
Internal: http://192.168.1.156:8123

Configuration.yaml http section is:

http:
    base_url: https://hass.mydomain.com
    use_x_forwarded_for: true
    trusted_proxies:
        - 127.0.0.1

I am making the assumption that because accessing portainer is working that the issue is not with caddy and I am failing to ensure that home assistant is correctly setup.

Much appreciation in advance for any insights you may have into fixing my situation.

Solved!

Unclear why but it appears with trusted proxy I cannot use 127.0.0.1
Once I changed it to the internal IP address of the NUC access is working as it should!