OPNsense Forum

English Forums => Web Proxy Filtering and Caching => Topic started by: bunchofreeds on October 12, 2022, 11:36:08 pm

Title: HAproxy - Home Assistant - Refresh
Post by: bunchofreeds on October 12, 2022, 11:36:08 pm
Hi,

I have Home Assistant running behind HAproxy on OPNsense successfully.

My issue is that on the first browse to home assistant (opening home assistant in a new browser session), it seems to complete one refresh after about 30 seconds. This returns you to the login screen.
After this it is fine and keeps you logged in.
Opening another tab and logging into Home Assistant after this does not cause the refresh.

The android app works fine.

I've read a bit about possible timeouts and entering extended times into HAproxy.
OPNsense/HAproxy has a web GUI and I'm not sure where to enter these options as the GUI does not seem to match what would be put into HAproxy config.

Home Assistant configuration.yaml has 'use_x_forwarded_for: true' and my OPNsense as trusted.

Has anyone encountered this or have any ideas how to resolve it? 
Title: Re: HAproxy - Home Assistant - Refresh
Post by: cweakland on December 01, 2022, 05:40:30 pm
Just found your post, I have the exact same issue on Pfsense w/HAproxy! I don't have a solution but the issue is the same for me.

1. Only in a new browser session (not a tab).
2. I access the main HASS page via haproxy.
3. I can log in or not, but after about 10-12 seconds I get a page reload. This reload comes from a client "get" request to /auth/authorize, and a redirect to https://<mydomain.com>/?auth_callback=1

I cant figure out why the client does this when connected to HASS via HAproxy vs directly to the server.
Title: Re: HAproxy - Home Assistant - Refresh
Post by: mnaim on December 06, 2022, 04:19:33 pm
I have home assistant behing HAproxy too. But what you are describing is happening to me even if go directly in LAN to home assistant server bypassing HAproxy.

Probably issue with home assistant based on:
https://community.home-assistant.io/t/home-assistant-portal-keeps-logging-me-out/430427
https://community.home-assistant.io/t/login-page-over-and-over/83522
https://community.home-assistant.io/t/logged-out-on-each-refresh/112801/5
Title: Re: HAproxy - Home Assistant - Refresh
Post by: cweakland on March 18, 2023, 04:49:14 pm
I believe I found a fix for you. In HAProxy, do you have a single frontend servicing multiple backends? If so, move your Home Assistant frontend configuration to the top of the list. This seems to work for me.