Skip to content

Instantly share code, notes, and snippets.

@Prophet-Phoenix
Last active May 2, 2021 19:55
Show Gist options
  • Save Prophet-Phoenix/d2c3535a44b689dca816bb66d3e95951 to your computer and use it in GitHub Desktop.
Save Prophet-Phoenix/d2c3535a44b689dca816bb66d3e95951 to your computer and use it in GitHub Desktop.
Caddyfile for Nextcloud 21 and Caddy 2.4
# Thanks to https://caddy.community/
example.com {
## optional logging here
# Change root path accordingly
root * /usr/local/www/nextcloud
file_server
encode gzip zstd
## Recommended version of php for Nextcloud 21 is 7.4
## Uncomment one of the following and edit accordingly
# php_fastcgi 127.0.0.1:9000 {
# php_fastcgi unix//var/run/php/php-fpm7.4.sock {
env PATH /bin
env front_controller_active true
}
# Only one header is needed, as nextcloud sets the rest
header {
Strict-Transport-Security "max-age=15768000;"
}
# Redirect dav access
redir /.well-known/cardav /remote.php/dav 301
redir /.well-known/caldav /remote.php/dav 301
# .htaccess, /data /config, etc. shouldn't be accessible from outside
@forbidden {
path /.htaccess
path /data/*
path /config/*
path /db_structure
path /.xml
path /README
path /3rdparty/*
path /lib/*
path /templates/*
path /occ
path /console.php
}
respond @forbidden 404
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment