Hassio + Caddy - 400 Bad Request

Hi,

I am running Hassio with Caddy + Cloudflare to access remotely securely on a raspberry PI and the same PI I have OMV 6, Portainer, Jellyfin, NextCloud and Duplicati.

My domain name is already working with nextcloud and jellyfin but I am unable to setup it up for Hassio as I am getting 400: Bad Request

Caddyfile config

hassio.domainname {
reverse_proxy 192.168.1.110:8123

Configuration.yaml

server_host: 192.168.1.110:8123
  base_url: domainname
  use_x_forwarded_for: true
 
  trusted_proxies: localhost

Please advise where am I wrong? thanks in advance.

Please fill out the help topic template. You didn’t provide enough information for us to help.

1. Caddy version (caddy version):

v2.4.6

2. How I run Caddy:

caddy start

a. System environment:

debian on pi 4, with omv, portainer, nextcloud, jellyfin

b. Command:

caddy adapt
caddy run
caddy stop

d. My complete Caddyfile or JSON config:

cloud.domainname {

rewrite /.well-known/carddav /remote.php/dav
rewrite /.well-known/caldav /remote.php/dav


reverse_proxy 192.168.1.110:8085
}

media.domainname {
reverse_proxy 192.168.1.110:8096
}

hassio.domainname {
reverse_proxy 192.168.1.110:8123
}

vault.domainname {
reverse_proxy 192.168.1.110:8880
}


3. The problem I’m having:

i have my domain name working for media server and cloud server but not for hassio

4. Error messages and/or full log output:

400:Bad Request

Those aren’t Caddy’s logs. That’s just what a single request returned.

When you run Caddy with caddy start, you lose Caddy’s logs, because it writes them to stdout/stderr by default, but that does nowhere when running detached.

I strongly recommend running Caddy as a systemd service instead. Depending on how you installed Caddy (which is a question in the help template that you didn’t answer), you might already be set up for this, if you installed Caddy with the apt package. There’s instructions here for how to use Caddy when running as a service:

That said, since your problem seems to be with home assistant, make sure it’s properly configured to work behind a proxy:

From Hassio i have the setup as mentioned in the above link but from caddy I am getting the below:

so i installed caddy using the below commands

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo tee /etc/apt/trusted.gpg.d/caddy-stable.asc
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

when I run caddy using “systemctl status caddy”

● caddy.service - Caddy
     Loaded: loaded (/lib/systemd/system/caddy.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2022-02-17 21:41:58 EET; 2min 5s ago
       Docs: https://caddyserver.com/docs/
   Main PID: 28564 (code=exited, status=1/FAILURE)
        CPU: 126ms

Feb 17 21:41:58 mabe.live caddy[28564]: NOTIFY_SOCKET=/run/systemd/notify
Feb 17 21:41:58 mabe.live caddy[28564]: HOME=/var/lib/caddy
Feb 17 21:41:58 mabe.live caddy[28564]: LOGNAME=caddy
Feb 17 21:41:58 mabe.live caddy[28564]: USER=caddy
Feb 17 21:41:58 mabe.live caddy[28564]: INVOCATION_ID=ac079a56080645ee813ba1fe340c08f6
Feb 17 21:41:58 mabe.live caddy[28564]: JOURNAL_STREAM=8:7332551
Feb 17 21:41:58 mabe.live caddy[28564]: run: reading config file: open /etc/caddy/Caddyfile: no such file or directory
Feb 17 21:41:58 mabe.live systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE
Feb 17 21:41:58 mabe.live systemd[1]: caddy.service: Failed with result 'exit-code'.
Feb 17 21:41:58 mabe.live systemd[1]: Failed to start Caddy.

it is saying above there is no Caddyfile although my Caddyfile is in /srv/dev-disk-by-uuid-ef44b7f7-dd47-45d0-ae6f-9aa2d989a7f3/Config/caddy

You need to move your configuration to /etc/caddy/Caddyfile, which is where Caddy is looking for your config, as per the systemd service config.

okay now my caddy is running fine

addy.service - Caddy
     Loaded: loaded (/lib/systemd/system/caddy.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-02-17 22:05:26 EET; 11s ago
       Docs: https://caddyserver.com/docs/
   Main PID: 10049 (caddy)
      Tasks: 11 (limit: 4915)
        CPU: 1.611s
     CGroup: /system.slice/caddy.service
             └─10049 /usr/bin/caddy run --environ --config /etc/caddy/Caddyfile

but I am getting error on all my pages with Error 525 SSL handshake failed, what should I fix now since i moved my Caddyfile, would you be aware?

Would appreciate your input here anyone.

Status code 525 is usually a problem with CloudFlare.

This topic was automatically closed after 30 days. New replies are no longer allowed.