Hi
With the latest update of home assistant v2021.7.0 I started getting “400 Bad Request” error when I tried to access HA via my external http/https address. I could still access home assistant without error via the local IP address.
If you check out the breaking changes if you are running a proxy you need to add
http:
use_x_forwarded_for: true
trusted_proxies:
- XXX.XXX.XXX.XXX # Add the IP address of the proxy server
Reference - HTTP - Home Assistant
However it still didn’t work for me. I tried using the IP address of my local server and also my WAN address but I was still getting the error! It’s because you need to use the internal docker IP address for your proxy container…
The solution is to check the home assistant log file for the internal docker IP proxy address to use.
Here is the relevant entry in the home assistant log file:
"A request from a reverse proxy was received from 172.18.0.4, but your HTTP integration is not set-up for reverse proxies"
You can generate this error in your log file by removing the http proxy setup from your configuraiton.yaml and then restart home assistant and try to access home assistant and generate the bad request error, then you can search the log file for the correct IP address to use.
… Or you can also find the correct IP address using portainer under
Networks → Compose_Default. Then scroll down and find the Lets_Encrypt docker container docker IP address.
… Or you can use the command line
List all docker networks:
docker network ls
Inspect a specific network to find the IP address of a container:
docker network inspect <network_name>
Hope that helps someone!