Caddy reverse proxy issue

Sonarr version (exact version):
Mono version (if Sonarr is not running on Windows): Windows
OS: Windows 10 Ent
Debug logs: Debug and trace:,

Description of issue:
Having a weird issue with Sonarr behind a caddy reverse proxy where caddy passes through to Sonarr but Sonarr throws a 400 back (HTTP Error 400. The request hostname is invalid.)
Sonarr works fine on the host through localhost:8989, and that’s what I’m forwarding to in caddy.
Initially I thought it was a caddy issue but have eliminated that with the team on the caddy forum.

I’ve added debug and trace logs here in the hope it might enlighten someone - I couldn’t find anything relevant but not really sure what I’m looking for.

Hopefully someone can help, it’s been driving me nuts.

EDIT: Sonarr config file if helpful

  <ApiKey> </ApiKey>

Have you tried running Sonarr once as an admin? That’ll register all hostnames on the 8989 port, it’ll also open the firewall port (so disable that if you want). I suspect that caddy is passing the request URL to Sonarr and because that URL is rejected by http.sys it’s failing.

Thanks Marcus. I’ve got it working for now. Seems like a combination of things. The run as admin definitely helped, but also seems Sonarr throws back everything as /sonarr/. Declaring /sonarr* in caddy helped.

If you set a URL base of /sonarr then yes, if you just want to work then you can remove the URL base.