Skip to content

Instantly share code, notes, and snippets.

@LukaHarambasic
Last active January 11, 2021 22:25
Show Gist options
  • Save LukaHarambasic/1acca157e307f8bc8725e63c3c327a77 to your computer and use it in GitHub Desktop.
Save LukaHarambasic/1acca157e307f8bc8725e63c3c327a77 to your computer and use it in GitHub Desktop.
Docker Compose for NextCloud with Traefik 2 (SSL)
version: '3.7'
services:
db:
image: mariadb:latest
container_name: nextcloud_db
volumes:
- nextcloud-db:/var/lib/mysql
networks:
- default
restart: always
environment:
TZ: UTC
MYSQL_ROOT_PASSWORD: SUPER_SECRET
MYSQL_DATABASE: db
MYSQL_USER: admin
MYSQL_PASSWORD: SUPER_SUPER_SECRET
redis:
image: redis:latest
container_name: nextcloud_redis
restart: always
networks:
- default
volumes:
- nextcloud-redis:/var/lib/redis
nextcloud:
depends_on:
- redis
- db
image: nextcloud:stable
container_name: nextcloud
volumes:
- nextcloud-data:/var/www/html
networks:
- web
- default
restart: always
labels:
- traefik.http.routers.nextcloud.middlewares=nextcloud,nextcloud_redirect
- traefik.http.routers.nextcloud.tls=true
- traefik.http.routers.nextcloud.tls.certresolver=lets-encrypt
- traefik.http.routers.nextcloud.rule=Host(`cloud.YOUR-DOMAIN.com`)
- traefik.http.middlewares.nextcloud.headers.customFrameOptionsValue=ALLOW-FROM https://YOUR-DOMAIN.com
- traefik.http.middlewares.nextcloud.headers.contentSecurityPolicy=frame-ancestors 'self' YOUR-DOMAIN.com *.YOUR-DOMAIN.com
- traefik.http.middlewares.nextcloud.headers.stsSeconds=155520011
- traefik.http.middlewares.nextcloud.headers.stsIncludeSubdomains=true
- traefik.http.middlewares.nextcloud.headers.stsPreload=true
- traefik.http.middlewares.nextcloud.headers.customresponseheaders.X-Frame-Options=SAMEORIGIN
- traefik.http.middlewares.nextcloud_redirect.redirectregex.permanent=true
- traefik.http.middlewares.nextcloud_redirect.redirectregex.regex=https://(.*)/.well-known/(card|cal)dav
- traefik.http.middlewares.nextcloud_redirect.redirectregex.replacement=https://$${1}/remote.php/dav/
environment:
REDIS_HOST: redis
MYSQL_HOST: db:3306
MYSQL_DATABASE: db
MYSQL_USER: admin
MYSQL_PASSWORD: SUPER_SUPER_SECRET
TRUSTED_PROXIES: 172.18.0.1
networks:
web:
external: true
volumes:
nextcloud-data:
nextcloud-db:
nextcloud-redis:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment