Proper WebDAV redirects for Nextcloud with Docker Labels
Proper WebDAV redirects for Nextcloud with Docker Labels
Background
I’m running Nextcloud as a Docker container, behind Traefik as a Reverse Proxy.
This was tested with Nextcloud version 14.0.4
and Traefik 1.7.4
.
The Warning
Once you have Nextcloud set up and are logged in, if you navigate to: https://subdomain.domain.com/settings/admin/overview, you should see a list of security recommendations, some of them being these:
Your web server is not properly set up to resolve "/.well-known/caldav". Further information can be found in the documentation.
Your web server is not properly set up to resolve "/.well-known/cardav". Further information can be found in the documentation.
More info on this recommendation from Nextcloud: https://docs.nextcloud.com/server/14/admin_manual/issues/general_troubleshooting.html#service-discovery
The Fix
Add these two labels
to the labels for the Nextcloud container/service, depending upon your setup.
- "traefik.frontend.redirect.regex=^https?://subdomain.domain.com/.well-known/(carddav|caldav)"
- "traefik.frontend.redirect.replacement=https://subdomain.domain.com/remote.php/dav"
Then restart the container/service. The error should no longer be present.
Gotchyas
Remember, if you’re running Docker in Swarm mode, the labels needs to be in the deploy
level scope. If you’re running it with just docker-compose
or docker run
, then put them at the service
level scope.