Error:
While running home-assistant (using docker) behind a reverse proxy such as nginx, if you get 400: Bad request
response codes. Check the error log for the HomeAssistant container:
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
Unable to find configuration. Creating default one in /config
2025-01-29 11:56:09.321 ERROR (MainThread) [homeassistant.components.http.forwarded] A request from a reverse proxy was received from 192.168.96.1, but your HTTP integration is not set-up for reverse proxies
2025-01-29 11:56:09.479 ERROR (MainThread) [homeassistant.components.http.forwarded] A request from a reverse proxy was received from 192.168.96.1, but your HTTP integration is not set-up for reverse proxies
Fix:
Edit config/configuration.yaml
and add:
http:
use_x_forwarded_for: true
trusted_proxies:
- 127.0.0.1
- 192.168.96.1
ip_ban_enabled: true
login_attempts_threshold: 5
Add the above line of code just below the default_config:
in the config/configuration.yaml
. If your reverse proxy is running on another host, replace 127.0.0.1
by the IP address of that host.
Now restart home-assistant and your reverse proxy should work fine.
docker restart homeassistant