Hey I’ve been using home assistant for a little while now and have it configured with a cert from let’s encrypt probably similar to how many of you do it.
I’ve recently stood a couple other servers up and have decided to make a reverse proxy using caddy so that I can just manage one cert for everything.
Now I can reach the frontend by IP address, but not when going through the reverse proxy. The gives me an error in caddy: -0700 [ERROR 502 /favicon.ico] tls: oversized record received with length 20527 and the web browser responds with 502 Bad Gateway
What am I missing? Is there some other configuration that’s required for using hass behind a reverse proxy?
http:
# Secrets are defined in the file secrets.yaml
api_password: !secret frontend
base_url: mydomain.com:8123
trusted_networks:
- 127.0.0.1
- ::1
I had no trouble making it work as a subdomain (like the example on hass.io docs) but did have trouble making it work as a subdirectory, so I abandoned that.
the only real caveat is that all logins come from the IP of your reverse proxy server, which is stated in hass.io docs, so you probably want a password and no ip_ban_enabled
@avalanchevm thanks for putting your resolution up!
I will attempt this probably tonight and wanted to ask can you add other devices to your caddy file? If so, any chance you can post a copy of your caddy file? I want to add a few other devices and trying to make it as neat as possible.
I use 127.0.0.1 and ::1 as trusted proxy as well as x_forwarded_for and ipbans and it works fine. I was getting banned every couple of weeks on 127.0.0.1 before I did that… No idea why but it would just suddenly stop working.
I also use that authenticated sensor that logs every successful login which is useful as well.
After adding use_x_forwarded_for: true I never had a ban for 127.0.0.1. But with this configuration I have sometimes error with mobile Chrome (Android 8/9). I don’t know that is a HA, Caddy or my configuration isuue.
I don’t think so. If I connect on localipaddress:8123 it occasionally does it as well. What do you mean by “I changed Caddy on nginx” Are you indicating you use both?
i’m not forcing anybody so you have to decide that for yourself
if you really want to disable http2 only on one of your sites you could also use the tls directive in combination with the alpn subdirective in your Caddyfile. but I would first try the flag to see if the retry problem goes away. if it does you can tinker with the finer grained configuration options…
i’m not deep enough in the technical details why the browser accepts that communication on the 2nd try. if somebody has a deeper knowledge on that topic please let us know
lucky you! most of the people i know that used an http2 enabled proxy with home assistant saw that retry button each and every time they tried to connect.