diff --git a/nextcloud/nginx.conf b/nextcloud/nginx.conf index b4e4b5a..9f0a005 100644 --- a/nextcloud/nginx.conf +++ b/nextcloud/nginx.conf @@ -35,20 +35,9 @@ server { location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; } location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; } - # Serve static files directly, fall through to PHP for dynamic assets (e.g. theming) - location ~ \.(?:css|js|mjs|svg|gif|ico|jpg|png|webp|wasm|tflite|map|ogg|flac|mp4|webm)$ { - try_files $uri /index.php$request_uri; - add_header Cache-Control "public, max-age=15778463$asset_immutable"; - access_log off; - } - - location ~ \.woff2?$ { - try_files $uri /index.php$request_uri; - expires 7d; - access_log off; - } - - # PHP handling + # PHP handling (must be before static file locations so that internal + # redirects like /index.php/apps/theming/theme/dark.css match here + # instead of cycling back into the static file try_files) location ~ \.php(?:$|/) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; set $path_info $fastcgi_path_info; @@ -66,6 +55,19 @@ server { fastcgi_max_temp_file_size 0; } + # Serve static files directly, fall through to PHP for dynamic assets (e.g. theming) + location ~ \.(?:css|js|mjs|svg|gif|ico|jpg|png|webp|wasm|tflite|map|ogg|flac|mp4|webm)$ { + try_files $uri /index.php$request_uri; + add_header Cache-Control "public, max-age=15778463$asset_immutable"; + access_log off; + } + + location ~ \.woff2?$ { + try_files $uri /index.php$request_uri; + expires 7d; + access_log off; + } + # Default handler — route everything else through PHP front controller location / { rewrite ^ /index.php$request_uri last;