docker 运行 home-assistant 后使用 nginx 正常反代,发现出现 400 错误连不上!
看了下 ha 的日志:
2024-05-05 19:54:59.345 ERROR (MainThread) [homeassistant.components.http.forwarded] A request from a reverse proxy was received from 172.17.1.3, but your HTTP integration is not set-up for reverse proxies
2024-05-05 19:54:59.413 ERROR (MainThread) [homeassistant.components.http.forwarded] A request from a reverse proxy was received from 172.17.1.3, but your HTTP integration is not set-up for reverse proxies
2024-05-05 19:55:11.768 ERROR (MainThread) [homeassistant.components.http.forwarded] A request from a reverse proxy was received from fd01::3, but your HTTP integration is not set-up for reverse proxies
原因是 ha 默认限制本机(127.0.0.1)以外的端口转发,修改下 ha config 文件夹下的 configuration.yaml
文件,添加如下配置(修改成 nginx 反代的网段):
http:
use_x_forwarded_for: true
trusted_proxies:
- 172.17.1.0/24
- fd01::/64
保存后,重启下 ha,不出意外的话,即可正常访问啦~
Comments NOTHING