The problem
I am trying to make trusted_network auth work when accessing Home Assistant from my LAN. Sometime in the past it used to work and then it stopped, this was so long ago that I can't really remember which version it happened with. Anyway, I've got visitors on the way and thought I should make an effort to make this work again as I think creating a guest-user is an ugly workaround.
If I don't set any http: config then trusted_networks works when accessing HA directly on its local IP and port, however this completely breaks my reverse proxy making it just say "400: Bad Request" whether I'm accessing the reverse proxy from the LAN or from the internet.
If I set the http: config as seen in my attached example then my reverse proxy works but if I click on the trusted networks login on the HA login page it just tells me "Login aborted: Your computer is not allowed.". This happens both if I go directly to the IP and port, or if I go through the reverse proxy.
I've got hairpin NAT configured in my router so when you access the external URL from inside my LAN it appears as if I'm accessing HA directly from my routers IP in the HA access logs (192.168.1.1), while I get my correct LAN IP (192.168.11.30) if I go directly to the IP and port HA is running on. There are no errors or anything useful that appears in the logs I think but I've attached them anyway. Are there any other components I should enable logging for that would help? Just setting everything to debug makes way too big of a mess I feel.
What version of Home Assistant Core has the issue?
2022.9.1
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Container
Integration causing the issue
http
Link to integration documentation on our website
https://www.home-assistant.io/integrations/http#reverse-proxies
Diagnostics information
No response
Example YAML snippet
homeassistant:
# Name of the location where Home Assistant is running
name: ha
# Location required to calculate the time the sun rises and sets
latitude: !secret loc_lat
longitude: !secret loc_lon
# Impacts weather/sunrise data (altitude above sea level in meters)
elevation: 35
# metric for Metric, imperial for Imperial
unit_system: metric
# Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
time_zone: Europe/Stockholm
# Auth stuff
auth_providers:
- type: homeassistant
- type: trusted_networks
trusted_networks:
- 192.168.0.0/16
- 172.16.0.0/12
- 127.0.0.1
- ::1
# URL
external_url: https://ha.domain.tld
internal_url: http://192.168.11.31:8123
# Customization stuffs
customize: !include customize.yaml
# web ui and auth stuff
http:
use_x_forwarded_for: true
trusted_proxies:
- 192.168.0.0/16
- 172.16.0.0/12
- 127.0.0.1
- ::1
# logging
logger:
default: critical
logs:
homeassistant.components.http: debug
Anything in the logs that might be useful for us?
nuc :: ~ % docker logs -f homeassistant
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun home-assistant (no readiness notification)
s6-rc: info: service legacy-services successfully started
[19:33:44] INFO: Home Assistant Core finish process exit code 100
[19:36:57] INFO: Home Assistant Core finish process exit code 100
[20:04:39] INFO: Home Assistant Core finish process exit code 100
[20:12:00] INFO: Home Assistant Core finish process exit code 100
[20:13:54] INFO: Home Assistant Core finish process exit code 100
[20:15:06] INFO: Home Assistant Core finish process exit code 100
[20:48:32] INFO: Home Assistant Core finish process exit code 100
[20:50:25] INFO: Home Assistant Core finish process exit code 100
[20:57:34] INFO: Home Assistant Core finish process exit code 100
2022-09-10 20:57:35.686 INFO (MainThread) [homeassistant.components.http] Now listening on port 8123
2022-09-10 20:57:38.386 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.11.1 (auth: False)
2022-09-10 20:57:39.543 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/webhook/e4a613de1bc74f6253962913f2f11a7299c14d80cd84df71830d47cf97cf21cc to 40.74.19.186 (auth: False)
2022-09-10 20:57:49.493 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/providers to 192.168.11.30 (auth: False)
2022-09-10 20:57:49.670 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow to 192.168.11.30 (auth: False)
2022-09-10 20:57:52.628 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow/2e4e3ace0ca01464b2edca72c47a2a42 to 192.168.11.30 (auth: False)
2022-09-10 20:57:52.634 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow to 192.168.11.30 (auth: False)
2022-09-10 20:57:55.050 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow to 192.168.11.30 (auth: False)
2022-09-10 20:57:55.832 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow to 192.168.11.30 (auth: False)
2022-09-10 20:57:57.011 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow to 192.168.11.30 (auth: False)
2022-09-10 20:58:13.944 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/providers to 192.168.11.1 (auth: False)
2022-09-10 20:58:14.207 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow to 192.168.11.1 (auth: False)
2022-09-10 20:58:16.180 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow/026ea26a5a34c9629c1275c766e33c09 to 192.168.11.1 (auth: False)
2022-09-10 20:58:16.186 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow to 192.168.11.1 (auth: False)
2022-09-10 20:58:17.959 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow to 192.168.11.1 (auth: False)
2022-09-10 20:58:18.569 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow to 192.168.11.1 (auth: False)
Additional information
No response
The problem
I am trying to make trusted_network auth work when accessing Home Assistant from my LAN. Sometime in the past it used to work and then it stopped, this was so long ago that I can't really remember which version it happened with. Anyway, I've got visitors on the way and thought I should make an effort to make this work again as I think creating a guest-user is an ugly workaround.
If I don't set any
http:config thentrusted_networksworks when accessing HA directly on its local IP and port, however this completely breaks my reverse proxy making it just say "400: Bad Request" whether I'm accessing the reverse proxy from the LAN or from the internet.If I set the
http:config as seen in my attached example then my reverse proxy works but if I click on the trusted networks login on the HA login page it just tells me "Login aborted: Your computer is not allowed.". This happens both if I go directly to the IP and port, or if I go through the reverse proxy.I've got hairpin NAT configured in my router so when you access the external URL from inside my LAN it appears as if I'm accessing HA directly from my routers IP in the HA access logs (192.168.1.1), while I get my correct LAN IP (192.168.11.30) if I go directly to the IP and port HA is running on. There are no errors or anything useful that appears in the logs I think but I've attached them anyway. Are there any other components I should enable logging for that would help? Just setting everything to debug makes way too big of a mess I feel.
What version of Home Assistant Core has the issue?
2022.9.1
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Container
Integration causing the issue
http
Link to integration documentation on our website
https://www.home-assistant.io/integrations/http#reverse-proxies
Diagnostics information
No response
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
No response