HomeAssistant Reverse Proxy Configuration
Symptom
After enabling HomeAssistant, opening homeassistant.subdomain.domain
the browser reported a 400: Bad request.
Investigation
The Traefik dashboard showed that homeassistant was there. I could ping homeassistant.subdomain.domain
The systemd log showed the following for the homeassistant service:
Feb 21 20:38:56 elitedesk docker-compose[1771860]: homeassistant_1 | s6-rc: info: service s6rc-oneshot-runner successfully started
Feb 21 20:38:56 elitedesk docker-compose[1771860]: homeassistant_1 | s6-rc: info: service fix-attrs: starting
Feb 21 20:38:56 elitedesk docker-compose[1771860]: homeassistant_1 | s6-rc: info: service fix-attrs successfully started
Feb 21 20:38:56 elitedesk docker-compose[1771860]: homeassistant_1 | s6-rc: info: service legacy-cont-init: starting
Feb 21 20:38:56 elitedesk docker-compose[1771860]: homeassistant_1 | s6-rc: info: service legacy-cont-init successfully started
Feb 21 20:38:56 elitedesk docker-compose[1771860]: homeassistant_1 | s6-rc: info: service legacy-services: starting
Feb 21 20:38:56 elitedesk docker-compose[1771860]: homeassistant_1 | services-up: info: copying legacy longrun home-assistant (no readiness notification)
Feb 21 20:38:56 elitedesk docker-compose[1771860]: homeassistant_1 | s6-rc: info: service legacy-services successfully started
Feb 22 20:00:52 elitedesk docker-compose[1771860]: homeassistant_1 | 2023-02-22 20:00:52.392 ERROR (MainThread) [homeassistant.components.http.forwarded] A request from a reverse proxy was received from x.x.x.x, but your HTTP integration is not set-up for reverse proxies
Feb 22 22:36:07 elitedesk docker-compose[1771860]: homeassistant_1 | 2023-02-22 22:36:07.241 ERROR (MainThread) [homeassistant.components.http.forwarded] A request from a reverse proxy was received from x.x.x.x, but your HTTP integration is not set-up for reverse proxies
I looked up the last line on web search and found this https://community.home-assistant.io/t/http-integration-is-not-set-up-for-reverse-proxies/313284/4
I added the following to /var/homelab/homeassistant/configuration.yaml
:
http:
use_x_forwarded_for: true
trusted_proxies:
- x.x.x.x
- 127.0.0.1
- ::1
Where x.x.x.x
was what was shown in the systemd log. Then I restarted the service with make restart_one homeassistant
. The homeassistant.subdomain.domain
was available now.
Solution
I'm not sure what the solution is here. I could not find how the configuration.yaml
file is constructed in ansible or HomeLabOS. I'm guessing the default one in the image is being used here. Would a new one be included in the templates
directory for the homeassistant
role and then be copied into the homeassistant directory under /var/
? I'm also not sure how the IP address that is used is determined. Is that determined somewhere else in the system?
This was discussed on Zulip: https://homelabos.zulipchat.com/#narrow/stream/183614-new-members/topic/HomeAssistant/near/328993257