Home assistant (400 Bad Request) Docker + Proxy - Solution

Someone upvote this man!

In my case add all cloudflare proxies helped
http:
use_x_forwarded_for: true
trusted_proxies:
- 192.168.xxx.0/24 # You may also provide the subnet mask
- 192.168.xxx.xx # This is your local Nginx address if you have one
- 173.245.48.0/20
- 103.21.244.0/22
- 103.22.200.0/22
- 103.31.4.0/22
- 141.101.64.0/18
- 108.162.192.0/18
- 190.93.240.0/20
- 188.114.96.0/20
- 197.234.240.0/22
- 98.41.128.0/17
- 162.158.0.0/15
- 172.64.0.0/13
- 131.0.72.0/22
- 104.16.0.0/13
- 104.24.0.0/14

I am using Cloudflare tunnels and using the docker’s IP range worked for me.

    - 172.16.0.0/12  # Docker network range
    - 127.0.0.1  # Localhost
    - 192.168.1.0/24  # Local network
1 Like

YES Thank You Very much!
As this was the first time I set up an extra NGINX-server to proxy requests internally, I had like hundreds of possible causes for this Error 400. Although that it came from HA itself, somewhat gave it away. Your answer here, saved me a lot of time. Thanks!

1 Like

Hi guys after weeks of f***ing around. In your Nginx proxy server add the following to clear the X-Forwarded-For information passed on by Cloudflare:
proxy_set_header X-Forwarded-For “”;