Homeassistant behind caddy

I have pihole running on the device with apache2
and I have caddy running as well I have setup

I have also setup the ha.example.org to point to in the pihole

ha.example.org {
    tls {
        dns cloudflare _***************************u-VP

  # ip_ban_enabled: True
  login_attempts_threshold: 5
  base_url: https://ha.example.org
  use_x_forwarded_for: true

upon doing this I get 400: Bad Request error when visiting the domain

what am i doing wrong here ?

I don’t know caddy, but this problem is normally that only http request are proxied, and not the websockets. So probably adding websockets should fix it.

Not sure about cloudfare part, but here is mine. Been working well for years.

(logs) {
  log {
    output file /var/log/caddy/caddy.log {
      roll_size 5MiB
      roll_keep 5
      roll_keep_for 168h
    format console
(https_header) {
  header {
    Strict-Transport-Security "max-age=31536000; includeSubdomains; preload"
    X-XSS-Protection "1; mode=block"
    X-Content-Type-Options "nosniff"
    Referrer-Policy "same-origin"
    Content-Security-Policy "frame-ancestors xxx.org ha.xxx.org"
    Permissions-Policy "geolocation=(self) , microphone=()"

https://ha.xxx.org {
  import https_header
  tls /etc/letsencrypt/live/ha.xxx.org/fullchain.pem /etc/letsencrypt/live/ha.xxx.org/privkey.pem {
    alpn http/1.1
  import logs
  encode zstd gzip

Its being served on 443 externally, so you might need :port number at the start of the open brackets.