NGINX (Proxy Manager) + basic auth + websockets = experiencing issues

Tags: #<Tag:0x00007f326cd6d788> #<Tag:0x00007f326cd6d670> #<Tag:0x00007f326cd6d530>

Hey everyone,

I have been going crazy, trying to figure this one out but yet to find a solution. I am running Home Assistant Supervised 0.116.4 on Intel NUC. Now, I am trying to configure easy external access to the system with a custom domain.

I installed NGINX Proxy Manager addon and configured the domain I want to use and enabled websocket support. This part works ( I can access HA and all pages inside, Lets Encrypt installed SSL, etc.).

After adding basic HTTP auth (so I am not leaving the interfaces fully exposed), the connectivity issues start. Entering the basic auth credentials and then logging into HA instance is OK, but then, for some reason, I am getting 401 error (Authorization Required) when accessing other HA pages (e.g. logs). It seems that WebSockets URL are not being proxies properly or not passing the authentication header.

In NPM logs, I can see these lines:

[19/Oct/2020:11:18:22 +0200] - - 401 - GET https ha.example.com "/config/logs" [Client 12.12.12.12] [Length 574] [Gzip -] [Sent-to 192.168.0.198] "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36" "https://ha.example.com/config/dashboard"
[19/Oct/2020:11:18:24 +0200] - - 401 - GET https ha.example.com "/service_worker.js" [Client 12.12.12.12] [Length 574] [Gzip -] [Sent-to 192.168.0.198] "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36" "https://ha.example.com.xyz/service_worker.js"

Considering that I haven’t really made any changes to the networking/HTTP configuration of Home Assistant, do I miss on any configurations in NPM/Nginx itself to support basic auth? Any help here is appreciated, just point me in the right direction :slight_smile: