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

I have tried everything with this but still cannot get it to work.

I have a reverse proxy via IIS URL rewrite. The logs show the local gateway IP but always with a different port number after it. I’ve added my entire network (/24) to trusted_proxies and still same thing.

Thanks it worked for me. :+1:

1 Like

And yet a thank you!

Running traefik on docker… the log entry tip helped me


donde hay q escribir eso?

1 Like


You will need to add what i quoted earlier in your configuration file. The link below will tell you where to find your configuration file.
Configuration.yaml - Home Assistant (home-assistant.io)

Tienes que modificar tu documento manualmente, se llama: configuration.yaml

> http:
>   use_x_forwarded_for: true
>   trusted_proxies:
>     -

Ughh thank you so much. My Alexa integration had been broken by this and took me this long to figure out why.

1 Like

Thank you!

1 Like

This did the trick, thanks.

Is there a good way of configuring it so that it’s not sensitive to IP changes i.e. if the IP address of reverse proxy container changes in future?

1 Like

It seems to be static but you could just add the whole subnet if you wanted.

Thank you! You saved me a bunch of heart ache when I moved HA to docker.

1 Like

I think mine has dynamic ip:

Logger: homeassistant.components.http.forwarded
Source: components/http/forwarded.py:112
Integration: HTTP (documentation, issues)
First occurred: 9:51:20 PM (10 occurrences)
Last logged: 9:51:26 PM

  • Received X-Forwarded-For header from an untrusted proxy
  • Received X-Forwarded-For header from an untrusted proxy
  • Received X-Forwarded-For header from an untrusted proxy

Any idea how to deal with this?

@crpgbogor Try

1 Like

Thanks. I tried but still doesn’t work.
This is the error log:

  • Received X-Forwarded-For header from an untrusted proxy
  • Received X-Forwarded-For header from an untrusted proxy

Would it be possible if we just input the docker gateway? Anyone know how to obtain docker’s gateway using ssh?

Update: I input but still doesn’t work

This appears to be an issue with cloudflare proxy. When the proxy is turned off (DNS only), the page is resolving as normal.

I should probably enter cloudflare’s IP range into trusted proxy, but I have no idea the IP range they use.

Update: Finally solved.

I put all of cloudflare’s ip range in trusted proxy and it is now working as before. Thank you all for your help.

See Cloudflare’s IP range here.

This has been incredibly helpful, but I still have an issue happening.

  • I’m running on Synology DSM 7, with support for wildcard certs.
  • My DDNS subdomain for Home Assistant is ha.<mydomain>.synology.me.
  • I have set up the reverse proxy on my Synology
  • I have set up the HTTP x_forward/trusted proxy statements in HA, (clearing the 400 error).

I was so incredibly happy to see a Home Assistant login screen after doing this! But when I entered my credentials, and yes, I know they are correct, it seems I get logged in, but then something gets hung up, and I get the screen below.

The resulting URL that gets me the picture below is:


So it’s as if I’m logging in correctly, but then something is getting hung on the dashboards.

Any help??


Forgot to mention in the post above… I check home-assistant.log and there’s nothing at all… pretty frustrating.

Try https://ha..synology.me , same problem? Also press CTRL+SHIFT+F5.

kiwijunglist… yep, nothing works, even if actually typing the “https://” before my “ha” URL. Interesting issue… it’s making it to the HA instance and through the authentication (it looks like)… but the HA instance doesn’t like it after that.

Did you enable websockets on the nginx configuration?