I just put the Nextcloud related part into a separate file, as python-certbot-nginx creates a good ssl vhost automatically, where I just want to plug in the Nextcloud related parts. But the given config is just for SSL and I am not sure which parts are just valid for SSL connections and which could remain for pure non-SSL environments. Currently my config looks like this. Would be nice if someone could tell me which directives would need to be removed to work with non-SSL (HTTPS on, HSTS of course, but what about the X- security headers e.g.?):
location ^~ /nextcloud {
# set max upload size
client_max_body_size $(( $(php -r 'print(PHP_INT_MAX);') / 1024 / 1024))M;
fastcgi_buffers 64 4K;
# Enable gzip but do not remove ETag headers
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;
# Uncomment if your server is build with the ngx_pagespeed module
# This module is currently not supported.
#pagespeed off;
location /nextcloud {
rewrite ^ /nextcloud/index.php\$request_uri;
}
location ~ ^/nextcloud/(?:build|tests|config|lib|3rdparty|templates|data)/ {
deny all;
}
location ~ ^/nextcloud/(?:\.|autotest|occ|issue|indie|db_|console) {
deny all;
}
location ~ ^/nextcloud/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.php(?:$|/) {
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME \$request_filename;
fastcgi_param PATH_INFO \$fastcgi_path_info;
fastcgi_param HTTPS on;
# Avoid sending the security headers twice
fastcgi_param modHeadersAvailable true;
fastcgi_param REMOTE_USER \$remote_user;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_intercept_errors on;
# Disable because Jessie Nginx does not support that parameter
#fastcgi_request_buffering off;
}
location ~ ^/nextcloud/(?:updater|ocs-provider)(?:$|/) {
try_files \$uri/ =404;
index index.php;
}
# Adding the cache control header for js and css files
# Make sure it is BELOW the PHP block
location ~ \.(?:css|js|woff|svg|gif)$ {
try_files \$uri /nextcloud/index.php\$uri\$is_args\$args;
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
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;
# Optional: Don't log access to assets
access_log off;
}
location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
try_files \$uri /nextcloud/index.php\$uri$is_args\$args;
# Optional: Don't log access to other assets
access_log off;
}
# Hard coding 128M OPCache size, only for /nextcloud, to suppress warning on nextcloud admin panel.
fastcgi_param PHP_ADMIN_VALUE "opcache.memory_consumption=128";
}
Hehe no, I would always run everything only via SSL. But I am working on a better integration of Nextcloud installation within the DietPi SBC images. And there the installation should work correctly automated with every webserver, database and with+without SSL.
Establishing SSL is offered there via automated noIP + certbot, which creates it’s own SSL config, at least for apache and nginx. So the nextcloud.conf should just provide it’s own directory specific settings, plug&unplugable.