I have tried everything and I cannot for the life of me get reverse proxy working. [please help]

I have scoured the forums here as well as Reddit and Unraid, seen lots of people with similar/exactly the same issue I’m having. Most of the posts end with the OP getting a fix and I try the same things and NOTHING will work. All I ever get is “502 Bad Gateway”.
I’m running HA in an Unraid docker container with it’s own IP, I also have an Nginx Proxy Manager docker running. In my router I’m forwarding port 443-1443 on Nginx and 80 - 180 on Nginx. I have over a dozen other proxies set up and they all work absolutely fine, I really feel like the proxy set up for HA is needlessly complicated especially considering how many posts I’ve seen with similar issues. I get that it’s more secure the way it is now but it seems fkn impossible for me to set up.

I can connect to HA no problem locally with HOME ASSISTANT IP:8123, I can also connect through ‘MY DUCKDNS SUBDOMAIN:8123’ if I forward 8123 to HA in my router but I cannot connect through my own subdomain which is going down the exact same route. I have a c-name routing ‘home.MY DOMAIN’ straight to ‘MY DUCKDNS SUBDOMAIN’, in theory I should be able to go to ‘home.MY DOMAIN:8123’ no problem.

I have tried adding anything in my network that is along the route to the Trusted Proxies: section in the configuration.yaml, and tried changing the order of them. I got excited when I saw someone post to use 0.0.0.0/0 to whitelist all proxies but that doesn’t seem to work either. In Nginx I have Websocket support on, and tried every conbination of the other settings (force ssl, etc.), I don’t think it’s a problem with Nginx.

I can see the following error in the Nginx error log:

2022/01/18 13:15:26 [error] 21834#21834: *828767 connect() failed (113: Host is unreachable) while connecting to upstream, client: xx.xx.xx.xx (my ip), server: MY DOMAIN, request: “GET /lovelace HTTP/2.0”, upstream: “HOME ASSISTANT IP/lovelace”, host: “MY DOMAIN”

ps. apparently new users can only have 2 urls in a post for some stupid reason which is why all the “urls” are just me typing in caps because I’m so frustrated at this point.

UPDATE Jan-19
I’ve made some progress; I had the thought to try pinging my Unraid Server from the nginx docker container and discovered that it couldn’t get replies at all but only from my Unraid Server, I could ping everything else on the network just fine. I looked in to this and found that it’s a security feature for docker stuff and just had to turn it off in the Unraid docker settings.

I can now connect to HA and see my login screen with my domain through proxy, but alas, as soon as I enter my credentials all I get is and error with the HA Icon saying “Unable to connect to Home Assistant.”
I can see this in the Firefox Console:
“Firefox can’t establish a connection to the server at wss://home.MYDOMAIN/api/websocket.”
I’ve got Websocket support enabled in nginx so I still don’t know what the problem is.

I had a similar issue a few weeks ago when my internet connection went down, and I realised that my LOCAL access was relying on an internet connection - go figure!
Here’s the site I used to get me going - you need to get your head around what a reverse proxy is actually doing. Then it all makes perfect sense.

This article didn’t help unfortunately. I know how it’s all supposed to work, but something is failing somewhere along the line.
HOWEVER, I’ve made some progress; I had the thought to try pinging my Unraid Server from the nginx docker container and discovered that it couldn’t get replies at all but only from my Unraid Server, I could ping everything else on the network just fine. I looked in to this and found that it’s a security feature for docker stuff and just had to turn it off in the Unraid docker settings.

I can now connect to HA and see my login screen with my domain through proxy, but alas, as soon as I enter my credentials all I get is and error with the HA Icon saying “Unable to connect to Home Assistant.”
I can see this in the Firefox Console:
“Firefox can’t establish a connection to the server at wss://home.MYDOMAIN/api/websocket.”
I’ve got Websocket support enabled in nginx so I still don’t know what the problem is.

Have you ensured that you have the NGINX IP address added as a trusted proxy in your Home Assistant config?
I’m pretty sure that you will find an error in your Home Assistant log explaining that the connection was rejected because it was not a trusted proxy.

Yes my nginx IP in in the trusted proxy list. Home assistant shows no errors when I try to log in.

I don’t know what to suggest. There is still a lot that we don’t know but - I will lay out exactly how mine is setup so that you can compare.

  1. Home Assistant is NOT using SSL or Lets Encrypt, when I connect locally on port 8123 I am connecting directly to Home Assistant without SSL.
  2. I personally use the Nginx Core addon to provide the access to Home Assistant with SSL, but I have also set it up for a friend using Nginx Proxy Manager. All I need to do is point subdomain.maindomain.duckdns.org at the Home Assistant IP AND port 8123. It’s set to HTTP and all the options are turned on, HSTS, Websockets, HTTP2 etc. Then in the SSL page it’s set to force and it’s using Lets Encrypt certificate. This is all that was required to make it work.
  3. Port 80 and 443 are forwarded to the virtual machine running NGINX Proxy Manager on the router.

If you did already have encryption on Home Assistant, then you would need to tell NGINX Proxy Manager to use HTTPS to connect to Home Assistant, and not HTTP.

1 Like

I found I had to remove homeassistant.local with the actual IP address of where the home assistant was located. as soon as I did that…worked no issues.

1 Like