Need help with Nginx / ownCloud config


I moved ownCloud to a subdomain, which also means that the root of ownclouds nginx serverblock is now set to /var/www/owncloud/ instead of /var/www/.
My problem is that I am unable to get dietpi-owncloud.conf working properly. Could someone here help me out with this?

This is my dietpi-owncloud.conf:

# Based on:
location ^~ /owncloud {

	# Omit Nginx version on error response
	server_tokens off;

	# Add headers to serve security related headers
	add_header Strict-Transport-Security "max-age=15768000; includeSubDomains" always;
	add_header X-Content-Type-Options nosniff always;
	add_header X-Frame-Options "SAMEORIGIN" always;
	add_header X-XSS-Protection "0" always;
	add_header X-Robots-Tag "none" always;
	add_header X-Download-Options noopen always;
	add_header X-Permitted-Cross-Domain-Policies none always;
	add_header Referrer-Policy no-referrer always;

	# Set max upload size
	client_max_body_size 1048576M;
	# Do not set the number of buffers over 63, in our example it is set to 8.
	# When exeeding, big file downloads can possibly consume a lot of system memory over time and cause problems especially on low-mem systems.
	fastcgi_buffers 8 4K;
	# From ownCloud version 10.0.4 on, a header statement will be sent to nginx not to use buffers to avoid problems with problematic fastcgi_buffers values. See note above.
	# If these values are properly set and no problems are expected, you can turn on this statement to reenable buffering overriding the sent header.
	# In case you use an earlier version of ownCloud or can´t change the buffers, or you can´t remove a existing ignore header statement, you can explicitly set fastcgi_buffering off;
	# These statements are used either or but not together.
	fastcgi_ignore_headers X-Accel-Buffering;

	# Disable gzip to avoid the removal of the ETag header
	# Enabling gzip would also make your server vulnerable to BREACH
	# if no additional measures are done. See
	gzip off;

	error_page 403 /owncloud/core/templates/403.php;
	error_page 404 /owncloud/core/templates/404.php;

	location /owncloud {
		rewrite ^ /owncloud/index.php;

	location ~ ^/owncloud/(?:build|tests|config|lib|3rdparty|templates|data)/ {
		return 404;
	location ~ ^/owncloud/(?:\.|autotest|occ|issue|indie|db_|console) {
		return 404;

	location ~ ^/owncloud/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {
		fastcgi_split_path_info ^(.+\.php)(/.*)$;
		set $path_info $fastcgi_path_info;
		try_files $fastcgi_script_name =404;
		include fastcgi_params;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		fastcgi_param SCRIPT_NAME $fastcgi_script_name; # Necessary for owncloud to detect the contextroot
		fastcgi_param PATH_INFO $fastcgi_path_info;
		fastcgi_param HTTPS $https;
		fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice
		fastcgi_param front_controller_active true; # Enable pretty URLs without /index.php/
		fastcgi_read_timeout 180; # Increase default timeout e.g. for long running carddav/caldav syncs with 1000+ entries
		fastcgi_pass php;
		fastcgi_intercept_errors on;
		fastcgi_request_buffering off;

	location ~ ^/owncloud/(?:updater|ocs-provider|ocm-provider)(?:$|/) {
		try_files $uri $uri/ =404;
		index index.php;

	# Cache control for assets
	location ~ /owncloud/.*\.(?:css|js) {
		try_files $uri /owncloud/index.php$uri$is_args$args;
		expires 6M;
		access_log off; # Optional: Don't log access to assets

	location ~ /owncloud/.*\.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg|map|json) {
		try_files $uri /owncloud/index.php$uri$is_args$args;
		expires 2h;
		access_log off; # Optional: Don't log access to assets


you would need to adjust all locations and remove owncloud sub path.

I tried this before. But I found a location duplicate in default and dietpie-owncloud.conf that resulted into some issues. Pretty dumb that I haven’t seen this before. Now it works.

Thx for your effort. ^^

yes indeed, because root location is defined within default configuration as well and would need to be removed/adjusted. :slight_smile: