Home Assistant fails to load every time there's a new version when using Apache Reverse Proxy

I don’t know how else to debug this issue, but if there’s a new version of Home Assistant queued up in the Supervisor page, it coincides with my experience of not being able to load the UI via my domain.

I can still get to it locally, but until I update to the latest version, the https://subdomain.domain.com which is a sub-domain to my primary domain which is configured as a reverse proxy gives me the dreaded “retry” link.

I can’t make heads or tails of it. I just know that to fix it, I just update to the latest and restart everything.

Hi,
I have the same problem. I am using Apache2 as my reverse proxy, and until recently it worked fine.
I am running HA as a docker container, and the domain name is
https://home.mydomain.com

The relevant part of the conf file is

ProxyPass /api/websocket ws://localhost:8123/api/websocket
  ProxyPassReverse /api/websocket ws://localhost:8123/api/websocket
  ProxyPass / http://localhost:8123/
  ProxyPassReverse / http://192.168.0.7:8123/

  RewriteEngine on
  RewriteCond %{HTTP:Upgrade} =websocket [NC]
  RewriteRule /(.*)  ws://localhost:8123/$1 [P,L]
  RewriteCond %{HTTP:Upgrade} !=websocket [NC]
  RewriteRule /(.*)  http://localhost:8123/$1 [P,L]

I can still connect from within my home network by using http://192.168.0.7:8123 but get a 400 error from outside.
Logs say You have received a reverse proxy request from 127.0.0.1 but you ar enot set up to reverse proxy.
A bit or reading around and I added the following to the configuration.yaml file

http:
base_url: https://home.mydomain.com
  use_x_forwarded_for: true
  trusted_proxies:
    - 127.0.0.1 ----> Localhost
    - 172.16.0.0/12 ------>Docker Network
    - 192.168.0.0/24 ------> Home Network
    - ::1                      -------> IP6 (Dunno why, someone suggested it was a good idea ;-)
    - localhost           --------> Clutching at straws

And restart apache and the server…Makes no difference. I am sure I am missing something simple, but would appreciate any thoughts.

Same problem here…

My config is

<VirtualHost *:80>
  ServerName ha.*******.**

  ServerAdmin webmaster@localhost
  DocumentRoot /var/www/html

<Location "/">
    AllowMethods POST GET
</Location>

  ErrorLog ${APACHE_LOG_DIR}/ha-error.log
  CustomLog ${APACHE_LOG_DIR}/ha-access.log combined



  ProxyPreserveHost On
  ProxyRequests off
  ProxyPass /.well-known/ !
  ProxyPass / http://localhost:8123/
  ProxyPassReverse / http://localhost:8123/
  ProxyPass /api/websocket ws://localhost:8123/api/websocket
  ProxyPassReverse /api/websocket ws://localhost:8123/api/websocket

  RewriteEngine on
  RewriteCond %{REQUEST_URI} !^/.well-known/ [NC]
  RewriteCond %{HTTP:Upgrade} =websocket [NC]
  RewriteRule /(.*)  ws://localhost:8123/$1 [P,L]
  RewriteCond %{REQUEST_URI} !^/.well-known/ [NC]
  RewriteCond %{HTTP:Upgrade} !=websocket [NC]
  RewriteRule /(.*)  http://localhost:8123/$1 [P,L]
</VirtualHost>

I think you have to open the configuration.yaml file and add

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 127.0.0.1
    - 192.168.0.0/24

and then restart the docker container (For good luck I also restarted Apache2) and it worked.
HTH

No success
Same problem

Are you able to access the logs…I think you might see the ip address that is being used by the reverse proxy…Put that at the top of your list, and i think that will fix it

Wich log ?
Access log or error log ?

The log I accessed was home-assistant.log in the HA root directory
HTH

I read this in my log

2021-07-12 15:47:27 ERROR (MainThread) [homeassistant.components.http.forwarded] Received X-Forwarded-For header from an untrusted proxy ::1

This is what I added to config.yaml

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 127.0.0.1
    - 192.168.1.0/24

check your proxy IP and be sure its on trusted_proxies list.

I don’t know how to chek
Could you help me pls ?

where is your proxy server? is it on the same server or its running on a different machine?

Mine is on a different server, but the ip is already trusted…

I have Apache and HA on the same machine

if you know your IP then that IP should be the one you put as the trusted network

make sure you put the IP into your trusted network. Your HA running on Docker?

yes on Docker
127.0.0.1 (localhost) is trusted on code I copied on configuration.yaml

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 127.0.0.1
    - 192.168.1.0/24

I’m not sure the 2nd one is correct… anyway is it working? do you run HA on docker?

No It isn’t working
Yes…as I said I have HA on Docker

Any help ?