Looks like you’re proxying to an nginx server. Make sure it also passes through the X-Forwarded-Host
header to Nextcloud.
Ultimately, this isn’t an issue with Caddy. Caddy is working as intended here. You need to make sure everything upstream of Caddy is configured correctly.