External network access impossible for HA docker : Login attempt or request with invalid authentication from 93.22.XXX.XXX

Hello !

I just installed Home assistant in a docker.
Everything works perfectly with my internal network, but I still can’t access it through external network.

I host a few websites, so i put a proxy to redirect http port (for now) to the docker (80 to 8123) when coming from a specific domain : http://home.XXXXX.fr

Here my apache virtual host conf:

<VirtualHost *:80>
  ProxyPreserveHost On
  ProxyRequests Off
  ServerName www.home.XXXXX.fr
  ServerAlias XXXXX.fr
  ProxyPass / http://127.0.0.1:8123/
  ProxyPassReverse / http://127.0.0.1:8123/
</VirtualHost>

Here a part of my configuration.yaml :

http:
   base_url: http://www.home.XXXXX.fr
   use_x_forwarded_for: true
   trusted_proxies
      -  127.0.0.1

There is no error in the logs when I run home assistant.

When I try to authenticate with my username and password through external network :
image

Following line is appearing in logs when i click on “Retry” :

2019-12-11 20:26:44 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from 93.22.XXX.XXX

When i go on my profile with an internal network, I can see for each try :

Actualiser le jeton de http://www.home.XXXXX.fr/
Créé le 11 décembre 2019 à 20:26
Dernière utilisation le 11 décembre 2019 à 20:26 à partir de 93.22.XXX.XXX

I also tried with the android app with the exact same result.

I tried to add the following to http: without any change except there is no log when i try to authenticate:

  cors_allowed_origins:
     - http://www.home.XXXXX.fr

Have I done something wrong in the config ?
Is there something I can try ?

Thank you for your answers !

Did you check the documentation?

1 Like

I missed this part in the documentation and didn’t think about the websockets …

my new apache configuration :

<VirtualHost *:443>
  ServerName www.home.XXXXX.fr
  ProxyPreserveHost On
  ProxyRequests off
  ProxyPass /api/websocket ws://localhost:8123/api/websocket
  ProxyPassReverse /api/websocket ws://localhost:8123/api/websocket
  ProxyPass / http://localhost:8123/
  ProxyPassReverse / http://localhost: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]
</VirtualHost>

Thank you very much!