The Nextcloud Quick reference on Docker Hub states that there are two versions (apache or fpm) of the Nextcloud image. The apache version contains a full Nextcloud installation including an apache web server. The fpm version must be combined with any webserver that can proxy the http requests to the FastCGI-port of the container.
In the Quick reference fpm example, an nginx container is combined with the Nextcloud-fpm image and a MariaDB database container. If you would rather use Caddy in place of nginx, below you will find an equivalent fpm example that replaces nginx with Caddy v2 as the webserver.
docker-compose.yml:
version: '2'
volumes:
nextcloud:
db:
caddy_data:
services:
db:
image: mariadb
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
restart: always
volumes:
- db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=
- MYSQL_PASSWORD=
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
app:
image: nextcloud:fpm
links:
- db
volumes:
- nextcloud:/var/www/html
restart: always
web:
image: caddy
ports:
- 8080:80
links:
- app
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- caddy_data:/data
volumes_from:
- app
restart: always
Caddyfile:
:80 {
redir /.well-known/carddav /remote.php/dav 301
redir /.well-known/caldav /remote.php/dav 301
header {
# enable HSTS
# Strict-Transport-Security max-age=31536000;
}
# .htaccess / data / config / ... 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
root * /var/www/html
php_fastcgi app:9000
file_server
}
Reference: Dockerised Caddy V2 + Nextcloud-FPM to create an unsecured Nextcloud instance - #3 by basil