HSTS and DAV with Docker and Traefik

Nextcloud version: 18.0.4.2
Operating system and version: Debian 10
Apache or nginx version: nginx/1.16.1 (fpm-fcgi)
PHP version: 7.3.17

I’m getting these security warnings in my overview panel:

The "Strict-Transport-Security" HTTP header is not set to at least "15552000" seconds. For enhanced security, it is recommended to enable HSTS as described in the security tips ↗.

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/carddav". Further information can be found in the documentation.

How do I get these to work with with Traefik and Nextcloud running through docker-compose?

which traefik version are you using? the syntax is different between 1.7 and 2.

I’m using v2

Apr 29, 2020, 12:04 AM by noreply@nextcloud.com:

would this be helpful to you:

https://www.projekt-rootserver.de/nextcloud-docker-container/2019/09/2/

I don’t speak German, but I guess I can run it through a translator.

sorry for that. nevertheless i guess you can identify the code snippets with the labels for traefik.

in the meantime i got a merge request to my ansible playbook. maybe you can find what you are looking for there. i didn’t had time to check. but i’ll merge it later.

After adding these lines from that tutorial to my Nextcloud labels…

- "traefik.http.routers.nextcloud.middlewares=https-redirect@file"
- "traefik.http.routers.nextcloud-sec.middlewares = calcarddav, default-headers @ file"
- "traefik.http.middlewares.calcarddav.redirectregex.permanent = true"
- "traefik.http.middlewares.calcarddav.redirectregex.regex = https: // (. *) /.well-known/ (card | cal) dav"
- "traefik.http.middlewares.calcarddav.redirectregex.replacement = https: //$$1/remote.php/dav/"

…I get a 404 when visiting my Nextcloud subdomain, and Nextcloud disappears from my Traefik dashboard.