Help with Error 400: Bad Request

Please help. I have scoured the blogs for anything that might help and tried everything I can understand to try and I still end up with the same problem. 400: Bad Request everytime I try to access my Home Assitant from my domain. I am using AdGuard for DNS and DHCP, NGINX Proxy Manager for proxy, Let’s Encrypt for the certificarte, and cloudflare for my host. I have added in to my configuration.yaml:

http:
use_x_forwarded_for: true
trusted_proxies:
- 172.30.32.1
- 127.0.0.1
- 10.0.0.2

and nothing seems to work. I am at my rope’s end. I don’t know what logs I should post here to help show what’s going on so any direction would be helpful. I know I’m not the only one who has faced this issue and it seems that for most everyone adding in the above has solved the problem. I am using a RPi 4 8GB with a 500 GB SSD connected to my TP-Link router with the appropriate ports open. I have followed all the instructions and everything was working perfetly until the need to add the trusted_proxies section to configuration.yaml. Thank you for your time.

Show the error in your home-assistant.log. It contains the IP you need to add to trusted_proxies.

1 Like

Here is a copy of the log entry when I tried to access form the outside:

2021-09-25 19:25:54 ERROR (MainThread) [homeassistant.components.http.forwarded] Received X-Forwarded-For header from an untrusted proxy 172.70.98.43
2021-09-25 19:25:54 ERROR (MainThread) [homeassistant.components.http.forwarded] Received X-Forwarded-For header from an untrusted proxy 172.70.98.135
2021-09-25 19:25:55 ERROR (MainThread) [homeassistant.components.http.forwarded] Received X-Forwarded-For header from an untrusted proxy 172.69.35.164

As you can see they are all from different IP Addresses and one from another subnet.
Here’s another one a little later:

2021-09-25 19:42:09 ERROR (MainThread) [homeassistant.components.http.forwarded] Received X-Forwarded-For header from an untrusted proxy 108.162.215.105
2021-09-25 19:42:09 ERROR (MainThread) [homeassistant.components.http.forwarded] Received X-Forwarded-For header from an untrusted proxy 172.69.35.164
2021-09-25 19:42:11 ERROR (MainThread) [homeassistant.components.http.forwarded] Received X-Forwarded-For header from an untrusted proxy 108.162.215.105
2021-09-25 19:42:11 ERROR (MainThread) [homeassistant.components.http.forwarded] Received X-Forwarded-For header from an untrusted proxy 172.69.35.164
2021-09-25 19:42:11 ERROR (MainThread) [homeassistant.components.http.forwarded] Received X-Forwarded-For header from an untrusted proxy 172.70.98.43

So, yeah. No one else has run across this before from my research. I hope this means something to someone because I’m stumped.

You use the

proxies ?

use_x_forwarded_for: true
trusted_proxies:
  - 172.30.32.1
  - 127.0.0.1
  - 10.0.0.2
#log reported ipv4
  - 162.158.159.139
  - 172.69.55.59
  - 141.101.76.195
  - 141.101.98.91
  - 141.101.99.102
  - 141.101.105.87
  - 141.101.105.99
#cloudflare ipv4
  - 103.21.244.0/22
  - 103.22.200.0/22
  - 103.31.4.0/22
  - 104.16.0.0/13
  - 104.24.0.0/14
  - 108.162.192.0/18
  - 131.0.72.0/22
  - 141.101.64.0/18
  - 162.158.0.0/15
  - 172.64.0.0/13
  - 173.245.48.0/20
  - 188.114.96.0/20
  - 190.93.240.0/20
  - 197.234.240.0/22
  - 198.41.128.0/17
#cloudflare ipv6
  - 2400:cb00::/32
  - 2606:4700::/32
  - 2803:f800::/32
  - 2405:b500::/32
  - 2405:8100::/32
  - 2a06:98c0::/29
  - 2c0f:f248::/32

1 Like

Thanks, @francisp. I’ll give anything a try at. This point. I’ll let you know.

@francisp that did the trick! Thank you so very much. It never occured to me that the revers proxy could also be on the host’s side too.