Ok, this is a weird one. I’ve got a Pi that has been running Home Assistant in Docker (homeassistant/raspberrypi4-homeassistant:stable) for a while now and it’s always worked fine, up until this week. I had some unrelated network issues because of Pi-hole crashing and once I got that back up and running, my problems with Home Assistant somehow started.
My problem is that I can’t log in anymore, but only when using the externally available domain I have for it. When using the internal hostname and post 8123 it works just fine, so it’s really something reverse proxy related. When I try to log in using the domain name I pointed to it I get the login screen, but after entering my username and password I get a “Unable to connect to Home Assistant.” message with a retry button below it. The URL in the browser at that point is something like https://my.domain.name/lovelace?auth_callback=1&code=base64_data_here. If I look at my browser’s dev toolbar during that request I can see that there is a POST request to https://my.domain.name/auth/token that’s resulting in an error 400, Bad Request.
This is the relevant configuration I have set up in Home Assistant:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.1.203:80 0.0.0.0:* LISTEN -
tcp 0 0 192.168.1.203:8123 0.0.0.0:* LISTEN -
Just to reiterate, nothing seems to be wrong with Home Assistant itself. All my automations are working, all relevant ports are open and even the web UI is working, just not externally. Can any of you see something that I’m missing here?
I didn’t have anything relevant to this issue under the homeassistant entry in the config file, but I just attempted to add these two lines and it made no difference, sadly. Thanks for the suggestion though!
Ah, I should have mentioned that. I’m using a Synology NAS on the same network as a reverse proxy and for SSL termination since I have more services that I need a proxy for and most of them are running on the NAS. I used the graphical interface to add the different entries but I know it uses nginx to do it under the hood. The 192.168.1.203 IP mentioned above is the Pi that’s running HA, my NAS is available on the same network through 192.168.1.72.
Awesome, that fixed it. Weird though, I had that set up before and for some reason it was gone now, which is why I didn’t even look here. Let’s hope it sticks around this time.
You have a typo in your last header by the way, but I guess that means the last entry isn’t required.
I have the same issue with my own Apache 2.4 proxy, running on Digital Ocean VPS. Login form successfully rendered, and after that I got HTTP400 on /auth/token request. Do you have any idea how to fix it for Apache2? Here is my config