Remote access with Docker

I have a working SWAG installation in docker (I can access other services remotely, like https://navidrome.example.xyz), and I have a working Home Assistant in docker (which I can access locally via https://192.168.50.159:8123). And I’ve set up homeassistant.subdomain.conf as described in the top post.

However, when I try to connect with https://homeassistant.example.xyz I encounter a problem. I get the login page, followed by my 2FA prompt, but then I see a page that says “Unable to connect to Home Assistant. Retrying in XX seconds.” And that page just keeps reloading every 60 seconds.

For what it’s worth, I don’t have this problem when I’m using Caddy as my reverse proxy. I’m not complaining! Nothing against Caddy, but I’d like to get SWAG up and running as my reverse proxy.

Any ideas or suggestions? Many thanks.

EDIT: I found the solution in this link. In my homeassistant.subdomain.conf I had changed the first set $upstream_app to list my local ip instead of saying homeassistant but I didn’t see that there was a second instance of the same line in the next section down. Once I changed that second instance to my local ip, everything started working. (It’s always those little things that you overlook, isn’t it?)

Thanks for the tutorial! Seems I’m still struggling to get the proxy to work though.

What I’ve done:

  • enabled the proper port forwarding for 80 and 443
  • updated the /proxy-confs/homeassistant.subdomain.conf → set $upstream_app 192.168.x.x;
  • updated the configuration.yaml → even added 0.0.0.0/0 to rule out that I’m ‘blocking’ some IP

What I get:

  • no errors on home assistant docker
  • no errors on swag docker
  • no errors in the router logging (unifi ultra)
  • no connection to my_domain.duckdns.org either… :frowning:
  • no connection to homeassistant.my_domain.duckdns.org either… :frowning:

I do get a ‘can’t connect to server’ (Safari) or ‘ERR_CONNECTION_REFUSED’ (Chrome) which hints that something is blocking me.

any suggestions where to look? help is much appreciated! :slight_smile:

Hi,

If you try www.your_domain.duckdns.org does it take you to a swag welcome page?

If not, i’d suggest you check port forwarding.

if yes, check the proxy-confs/homeassistant.subdomain.conf has both $upstream_app entries; there are two.

Are you properly accessing from outside? eg from phone connected to data roaming with wifi off.

Not sure what else to suggest

Good luck

Hi, thanks for the reply! Nope, I won’t be seeing the swag welcome page and indeed I’m using both laptop (wifi) and phone (LTE) to check the connections. The port forwarding all looks just fine though.

On another instance I’m running Home Assistant OS with the proxy manager add-on (this is a separate rPi not running docker). In this case the proxy just works flawless and I can access home assistant local and remote. However, if I try to switch from proxy manager to NGINX reverse proxy I get the same behaviour as the docker setup. It seems that something with configuring the NGINX proxy goes wrong but there is not much to configure…

new lesson learned: after switch to reverse proxy, google assistant won’t be able to connect anymore :frowning:

sorry i can’t help more. with two systems set up like you have maybe certificates or something is interfering…way beyond me…

good luck

What seems to be the problem is not specifying the ports in the docker compose for swag. E.g. when I follow post #1 (where the ports 443 and 80 are commented out) the behaviour as described earlier is observed (e.g. cannot connect to server). When uncommenting the ports and restart the container all is fine and both swag and homeassistant are reachable. Is this a ‘fault’ in the tutorial?

Also I forgot this to add this to docker compose (although I’m not sure what it does)

# set trusted docker internal network
networks:
  default:
      ipam:  
        config: 
         - subnet: 172.10.0.0/24

side question: would it be possible to have my-domain.duckdns.org redirected to home assistant so that there is no need to add the ‘homeassistant’ prefix?

hi, sorry for the late reply

As home assistant requires ‘host’ mode for the network, the port mappings are not required and, on my set up, not even allowed.
Are you using the latest version of docker compose, if you are, I’ll need to double check my guide ( I hate guides that don’t work ). let me know.

re subnet: 172.10.0.0/24. Docker sets up its own network for containers to talk to each other. So this tells it to trust stuff coming from itself…

regarding the side question…duuh…not sure. The swag proxy directs incoming to the appropriate server. if you dont specify homeassistant, it assumes it is www.my-domain.duckdns.org and the www folder is used to give the default swag page. Maybe there is a way to change this but …don’t know…

Hi, no worries.

The installation is about 3 weeks old so I’m pretty much running the latest ;). Like said, when not adding the ports config it simply doesn’t work for some reason whereas with the ports configured in docker-compose all seems to be fine (e.g. no errors when starting the docker).

wrt the side-question; it’s allright. Was just wondering but since in practice you don’t type the link that much anyways it doesn’t really matter that much.

Edit 16/02:
Turned out that I was mixing the swag and homeassistant docker compose configs. Indeed, with host mode enabled, the port config won’t work. The manual is still valid :wink: