HomeAssistant / Hass.io with SWAG


meat

Recommended Posts

I am using the hassio_supervisor docker container which in turn installs several other containers in Docker including the homeassistant container.  I am also running the SWAG container which uses nginx for it's reverse proxy.  The problem I'm having is nginx requires a custom bridge network for it to route traffic to the proper container, in this case, the homeassistant container.  While I can set the network by editing the hassio_supervisor container, I am unable to edit the homeassistant container and it's using the host network.  Does anyone know of any workarounds for this?  I'm farily new to unRAID so I'm not sure if it's possible to edit containers from the terminal or if there are other ways to configure nginx files to map to containers on the host network.  Any help would be greatly appreciated.  I did come across this but I haven't given it a try yet: 

 

Link to comment
  • 1 month later...

Did you ever figure this out? I am running home assistant core in host network and swag on it's own network (that works as reverse proxy for those). If I change HA to network it stops working and if I point swag to HA in host mode, it doesn't see it.

 

Edit: Working - leave HA in host and in SWAG config, just point to IP

Edited by squish102
Link to comment
  • 2 weeks later...
On 1/16/2021 at 5:09 AM, BelgarionNL said:

where do you point to home assistant in the SWAG config?

 

Open the config and you will see two lines like below: 

 

"proxy_pass $upstream_proto://$upstream_app:$upstream_port;

 

Delete $upstream_app and repalce with IP of HA instance. You'll need to do it for both.

 

 proxy_pass $upstream_proto://10.1.1.200:$upstream_port; (For example)

 

Save config and restart SWAG.

  • Like 2
  • Thanks 1
Link to comment
  • 1 month later...

I keep having an issue where after I try to login via the cname I created I get a message that says "Unable to connect to Home Assistant." If I log in via the local IP it works fine. Im using the HA core docker and its network is set to host.

 

I was able to get it working adding these lines to my nginx config file

 

proxy_pass http://ip-address:8123;

proxy_set_header Host $host;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection "upgrade";

 

Anyone see any issues with adding these line?

Edited by TrueImpulse
Link to comment
  • 3 months later...
  • 3 months later...

@bigbangus

You would need to add the following lines to the configuration.yaml file:

 

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 172.XX.XX.XX # The SWAG docker IP address

 

You can always check for your SWAG docker IP address by checking it in the port mappings column of the Dockers tab.

Link to comment
  • 1 month later...

Worth sharing one more thing to simplify complications later on.  You can set the trusted_proxies value in the HomeAssistant configuration to the Docker IP Range!

This way if you ever have to change (or re-install SWAG; like I just had to do) you won't have a broken HomeAssistant instance (with no recollection of having worked all this very specific IP stuff out some time back)....
 

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 172.X.0.0/12 # The IP Range for SWAG docker IP address

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.