Setup
I’m running Home Assistant in a Docker container on my Synology NAS (DSM 7.x). Additionally, I have Cloudflared running in a separate Docker container on the same NAS to expose Home Assistant securely via a Cloudflare Tunnel, without any port forwarding.
Other services like EVCC, Paperless, Grafana, Mosquitto, etc. are also running in Docker and are fully accessible both internally and externally. Even the Synology itself is reachable via HTTPS without issues.
Goal
I want to securely access Home Assistant via a custom subdomain (e.g. https://ha.exampledomain.tld) using Cloudflare Tunnel. The tunnel is active, DNS is correctly configured, and the connection technically works — but Home Assistant blocks the request with the following error:
“A request from a reverse proxy was received from 192.168.x.x, but your HTTP integration is not set to use
trusted_proxies.”
Additionally, when accessing the subdomain via browser, I get:
“400: Bad Request”
Error Behavior
- The error only occurs when accessing Home Assistant via the Cloudflare subdomain
- Local access via IP or internal hostname works fine
- The “400 Bad Request” is triggered by Home Assistant when:
- The request comes from a proxy
- But the proxy IP is not listed in
trusted_proxies - Or the required headers (
X-Forwarded-For,X-Forwarded-Proto) are missing or malformed
Steps Already Taken
- Cloudflared is running in
hostnetwork mode (network_mode: host) - Tunnel is started using a token:
cloudflared tunnel run --token ... - In the Cloudflare Zero Trust dashboard:
- Public hostname:
ha.exampledomain.tld - Private IP:
192.168.x.x:8123 - Proxy type:
http - HTTP Host Header:
ha.exampledomain.tld
- In Home Assistant’s
configuration.yaml:
yaml
http:
use_x_forwarded_for: true
trusted_proxies:
- 127.0.0.1
- 192.168.x.x # Synology IP
- Home Assistant has been restarted multiple times
- Access via
https://ha.exampledomain.tldtechnically works, but the warning and 400 error persist
Questions
- Does Cloudflared need additional configuration to properly set
X-Forwarded-For? - Are there known issues when both Cloudflared and Home Assistant run in
hostnetwork mode? - Would moving Home Assistant to a
bridgenetwork help with proxy detection? - Is there a way to debug the actual headers Home Assistant receives?