Accessing HA externaly using apache2 as reverse proxy with ssl encryption

Hi fellow HA users,

I just installed HA using docker on an intel nuc.

I am using this nuc for serveral other services, such as nextcloud. I there fore have apache2 running on this nuc with a bunch of reverse proxy configured with ssl.

I am attempting to set up a reverse proxy for HA in a similar manner. I have configured apache2 to listen to a domain for HA and forward to port 8123. I am able to access the HA login page but when I try and login I am presented with a page saying that “unable to connect to Home Assistant”

Screenshot from 2023-01-31 18-29-32

I am able to login if I use the local ip and port 8123. There I can see the following log message.

Logger: homeassistant.components.http.ban
Source: components/http/ban.py:81
Integration: HTTP (documentation, issues)
First occurred: 18:09:58 (2 occurrences)
Last logged: 18:29:35

Login attempt or request with invalid authentication from _gateway (192.168.1.1). Requested URL: ‘/auth/token’. (Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36)

Initially I had an issue with not beeing able to load the login page. I got statuscode 400. This was resolved by adding:

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - "ip of the nuc hosting both apache and the docker container"

Any one have any ideas, suggestions or maybe guides I can follow?

All the guides I have found uses duckdns or other addons in HA to get ssl, but since this is handled by apache2 I’m thinking that this shouldn’t be necessary.

Thanks :slight_smile:

Are you forwarding websocket requests as well?

Hmm, that might be it.
Do you know how to add that in apache?

Have a look here: Reverse Proxy with Apache

Worked like a charm!
Thanks!!!

1 Like