ha.{$SUBDOMAIN}.{$DOMAIN} {
	log {
		output file /var/log/ha.log
	}

	route {
		@app <<CEL
				header({'X-Requested-With': 'io.homeassistant.companion.android'}) ||
				header_regexp('User-Agent', '^Home Assistant') ||
				header_regexp('User-Agent', 'Android')
		CEL
		handle @app {
			reverse_proxy host:8123
		}
		handle {
			reverse_proxy /outpost.goauthentik.io/* http://host:19000
			forward_auth http://host:19000 {
				uri /outpost.goauthentik.io/auth/caddy?rd={http.request.uri}
				copy_headers {
					X-Homeassistant-User
				}
			}
			reverse_proxy host:8123
		}
	}
}
