Hi everyone!
I want to serve a nextcloud server under my-nextcloud-site.com//nextcloud
I got the following caddy file from the examples [Nextcloud example] and adjusted the label (examples/Caddyfile at master · caddyserver/examples · GitHub):
my-nextcloud-site.com/nextcloud {
root /var/www/nextcloud
log /var/log/nextcloud_access.log
errors /var/log/nextcloud_errors.log
fastcgi / 127.0.0.1:9000 php {
env PATH /bin
}
rewrite {
r ^/index.php/.*$
to /index.php?{query}
}
# client support (e.g. os x calendar / contacts)
redir /.well-known/carddav /remote.php/carddav 301
redir /.well-known/caldav /remote.php/caldav 301
# remove trailing / as it causes errors with php-fpm
rewrite {
r ^/remote.php/(webdav|caldav|carddav|dav)(\/?)$
to /remote.php/{1}
}
rewrite {
r ^/remote.php/(webdav|caldav|carddav|dav)/(.+?)(\/?)$
to /remote.php/{1}/{2}
}
# .htaccess / data / config / ... shouldn't be accessible from outside
status 403 {
/.htacces
/data
/config
/db_structure
/.xml
/README
}
header / Strict-Transport-Security "max-age=31536000;"
}
My problem is, that I can’t get my head around the rewrites. If I go to my-nextcloud-site.com/nextcloud I get redirected to my-nextcloud-site.com/index.php. But unfortunately, this is not existing, because the subpath nextcloud is missing. I tried modifing the rewrites:
rewrite {
r ^/index.php/.*$
to /nextcloud/index.php?{query}
}
and this
rewrite /nextcloud {
r ^/index.php/.*$
to /index.php?{query}
}
But nothing is working and to be honest, I have no clue.
Could you please point me into the right direction? Maybe it’s not the rewrite directive at all?
PS: I tried serving the nextcloud server without the nextcloud subpath. This works as expected.
Thanks in advance!
Paul