Nextcloud version: nextcloud:21-fpm
Operating system and version: Ubuntu 18.0.4
nginx version: nginx:1
Docker version: 20.10.3, build 48d30b5
Docker Compose version: 1.28.2, build 67630359
I need help validating/improving next cloud configuration
${HOME}/docker-compose.yml
version: "3"
services:
db:
image: mariadb:10.5
container_name: mariadb
hostname: db
user: "${UID}:${GID}"
restart: always
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
networks:
- backend
volumes:
- ${DBVOL}:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=${MYSQLROOTPWD}
- MYSQL_DATABASE=${MYSQLDB}
- MYSQL_USER=${MYSQLUSR}
- MYSQL_PASSWORD=${MYSQLPWD}
redis:
image: redis:6.2
container_name: redis
hostname: redis
user: "${UID}:${GID}"
networks:
- backend
app:
depends_on:
- db
- redis
image: nextcloud:21-fpm
container_name: nextcloud
hostname: app
user: "${UID}:${GID}"
restart: always
networks:
- backend
volumes:
- ${APPVOL}/html:/var/www/html
- ${APPVOL}/apps:/var/www/html/custom_apps
- ${APPVOL}/config:/var/www/html/config
- ${HOME}/php/Setup.php:/var/www/html/lib/private/Setup.php
- ${HOME}/php/tweak.php:/usr/local/etc/php-fpm.d/tweak.php
- ${SHARE}:/var/www/html/data
environment:
- MYSQL_PASSWORD=${MYSQLPWD}
- MYSQL_DATABASE=${MYSQLDB}
- MYSQL_USER=${MYSQLUSR}
- MYSQL_HOST=db
- REDIS_HOST=redis
web:
depends_on:
- app
image: nginx:1
container_name: nginx
hostname: web
user: "${UID}:${GID}"
restart: always
ports:
- 80:80
- 443:443
networks:
- frontend
- backend
volumes:
- ${WEBVOL}/conf.d:/etc/nginx/conf.d
- ${WEBVOL}/dhparam:/etc/nginx/dhparam
- ${CAVOL}/conf:/etc/nginx/ssl
- ${CAVOL}/data:/usr/share/nginx/html/letsencrypt
volumes_from:
- app
ca:
depends_on:
- web
image: certbot/certbot:v1.10.0
container_name: certbot
hostname: ca
user: "${UID}:${GID}"
command: certonly --webroot --webroot-path=/usr/share/nginx/html/letsencrypt --email support@example.com --agree-tos --no-eff-email -d home.example.com
networks:
- backend
volumes:
- ${CAVOL}/conf:/etc/letsencrypt
- ${CAVOL}/logs:/var/log/letsencrypt
- ${CAVOL}/data:/usr/share/nginx/html/letsencrypt
cron:
depends_on:
- app
image: rcdailey/nextcloud-cronjob
container_name: cron
hostname: cron
user: "${UID}:${GID}"
restart: unless-stopped
networks:
- backend
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /etc/localtime:/etc/localtime:ro
environment:
- NEXTCLOUD_CONTAINER_NAME=app
- NEXTCLOUD_PROJECT_NAME=${HOME_FOLDER_NAME}
office:
image: onlyoffice/documentserver:6.2
container_name: onlyoffice
hostname: office
user: "${UID}:${GID}"
restart: always
networks:
- backend
volumes:
- ./onlyoffice/data:/var/www/onlyoffice/Data
- ./onlyoffice/log:/var/log/onlyoffice
networks:
frontend:
driver: bridge
backend:
driver: bridge
${WEBVOL}/conf.d/nextcloud.conf
upstream php-handler {
server app:9000;
}
map $http_host $this_host {
"" $host;
default $http_host;
}
map $http_x_forwarded_proto $the_scheme {
default $http_x_forwarded_proto;
"" $scheme;
}
map $http_x_forwarded_host $the_host {
default $http_x_forwarded_host;
"" $this_host;
}
server {
listen 80;
listen 443 ssl http2;
server_name home.example.com;
# Max allowed upload file in web page
client_max_body_size 20G;
if ($server_port !~ 443){
rewrite ^(/.*)$ https://$host$1 permanent;
}
# SSL and Support TLSv1.3
ssl_certificate /etc/nginx/ssl/live/home.example.com/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/live/home.example.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
error_page 497 https://$host$request_uri;
# add header information to fix Nextcloud console warning messages
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Permitted-Cross-Domain-Policies none;
add_header Referrer-Policy no-referrer;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
fastcgi_hide_header X-Powered-By;
root /var/www/html;
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location = /.well-known/carddav {
return 301 $scheme://$host/remote.php/dav;
}
location = /.well-known/caldav {
return 301 $scheme://$host/remote.php/dav;
}
# Enable gzip compression
gzip on;
gzip_vary on;
gzip_comp_level 4;
gzip_min_length 256;
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
# redirection and disable to access backend sensitive folders and resources
location / {
rewrite ^ /index.php$request_uri;
}
location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
deny all;
}
location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
deny all;
}
# PHP configuration
location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+)\.php(?:$|\/) {
fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
#Avoid sending the security headers twice
fastcgi_param modHeadersAvailable true;
fastcgi_param front_controller_active true;
fastcgi_pass php-handler;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
}
location ~ ^\/(?:updater|ocs-provider)(?:$|\/) {
try_files $uri/ =404;
index index.php;
}
location ~ \.(?:css|js|woff2?|svg|gif)$ {
try_files $uri /index.php$request_uri;
add_header Cache-Control "public, max-age=15778463";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
add_header Referrer-Policy no-referrer;
access_log off;
}
location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
try_files $uri /index.php$request_uri;
# Optional: Don't log access to other assets
access_log off;
}
location ~* ^/ds-vpath/ {
rewrite /ds-vpath/(.*) /$1 break;
proxy_pass http://onlyoffice;
proxy_redirect off;
client_max_body_size 100m;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $the_host/ds-vpath;
proxy_set_header X-Forwarded-Proto $the_scheme;
}
}