如何修复 Home-Assistant A request from a reverse proxy was received from 127.0.0.1, but your HTTP integration is not set-up for reverse proxies
问题:
在反向代理(如 nginx)后面运行 home-assistant(使用 docker 或其他方法)时,你会看到 400: Bad request 响应代码,并且 HomeAssistant 日志中出现以下错误消息:
home_assistant_reverse_proxy_error.log
homeassistant | 2021-11-25 03:03:59 ERROR (MainThread) [homeassistant.components.http.forwarded] A request from a reverse proxy was received from 127.0.0.1, but your HTTP integration is not set-up for reverse proxies解决方案
编辑 config/configuration.yaml 并添加:
configuration.yaml
http:
use_x_forwarded_for: true
trusted_proxies:
- 127.0.0.1
ip_ban_enabled: true
login_attempts_threshold: 5就在 default_config: 行下面,中间添加一个换行符。如果你的反向代理运行在另一台主机上,将 127.0.0.1 替换为该主机的 IP 地址。
完整的 configuration.yml 示例:
configuration.yaml
# 配置 Home Assistant 的默认设置(前端、api 等)
default_config:
http:
use_x_forwarded_for: true
trusted_proxies:
- 127.0.0.1
ip_ban_enabled: true
login_attempts_threshold: 5
# 文本转语音
tts:
- platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml现在重启 home-assistant,你的反向代理应该正常工作。
Check out similar posts by category:
Home-Assistant
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow