Hey everyone,
I’d like to setup Caddy with Nextcloud, but everything I try only results in errors.
I’m using abiosoft’s docker image for Caddy and the official Nextcloud fpm docker image for, well, Nextcloud. Unfortunately I can’t seem to get Caddy and Nextcloud working together.
My docker-compose looks like this (I’ve stripped down the whole thing):
version: "2"
services:
caddy:
image: abiosoft/caddy:php
container_name: caddy
restart: always
networks:
- proxy
ports:
- "80:80"
- "443:443"
environment:
CADDYPATH: "/etc/caddycerts"
ACME_AGREE: "true"
volumes:
- /root/compose/caddy/Caddyfile:/etc/Caddyfile
- /root/compose/caddy/certs:/etc/caddycerts
- /root/compose/caddy/www:/srv
- /var/www/nextcloud:/var/www/html
nextcloud:
image: nextcloud:15-fpm
container_name: nextcloud
restart: always
networks:
- proxy
volumes:
- /var/www/nextcloud:/var/www/html
networks:
proxy:
external: true
And my Caddyfile looks like this (again, a stripped down version only showing the necessary, configuration is take from the official caddy examplefiles):
example.org {
tls mail@example.org
on startup php-fpm7
root /var/www/html
errors /var/www/html/errors.log
log /var/www/html/access.log
browse
fastcgi / nextcloud:9000 {
env PATH /bin
}
header / {
Strict-Transport-Security "max-age=15768000;"
}
# checks for images
rewrite {
ext .svg .gif .png .html .ttf .woff .ico .jpg .jpeg
r ^/index.php/(.+)$
to /{1} /index.php?{1}
}
rewrite {
r ^/\.well-known/host-meta$
to /public.php?service=host-meta&{query}
}
rewrite {
r ^/\.well-known/host-meta\.json$
to /public.php?service=host-meta-json&{query}
}
rewrite {
r ^/\.well-known/webfinger$
to /public.php?service=webfinger&{query}
}
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}
}
rewrite {
r ^/public.php/(dav|webdav|caldav|carddav)(\/?)(\/?)$
to /public.php/{1}
}
rewrite {
r ^/public.php/(dav|webdav|caldav|carddav)/(.+)(\/?)(\/?)$
to /public.php/{1}/{2}
}
# .htaccess / data / config / ... shouldn't be accessible from outside
status 403 {
/.htaccess
/data
/config
/db_structure
/.xml
/README
}
}
But unfortunately, if I execute the whole thing, my browser shows only a “Access denied.”. Caddy redirects the traffic without any issues, but the nextcloud container shows the following (from docker-compose logs):
nextcloud | [09-Jan-2019 15:23:23] NOTICE: fpm is running, pid 1
nextcloud | [09-Jan-2019 15:23:23] NOTICE: ready to handle connections
nextcloud | [09-Jan-2019 15:23:29] WARNING: [pool www] child 17 said into stderr: "NOTICE: Access to the script '/var/www/html' has been denied (see security.limit_extensions)"
nextcloud | 172.21.0.5 - 09/Jan/2019:15:23:29 +0000 "GET /" 403
nextcloud | 172.21.0.5 - 09/Jan/2019:15:23:29 +0000 "GET /" 403
nextcloud | [09-Jan-2019 15:23:29] WARNING: [pool www] child 18 said into stderr: "NOTICE: Access to the script '/var/www/html' has been denied (see security.limit_extensions)"
Anyone got an idea on how to solve this? Or does anyone know how to use Caddy’s fpm module with an external container running php?! I’m trying since days to get any results but no matter what I try, it always fails the same way.
And I’d really like to use Nextcloud fpm.