Requests to index.php results in a 404

I installed nc12 on a nginx webserver (ispconfig as server control). The most nginx directives I got from here: https://docs.nextcloud.com/server/11/admin_manual/installation/nginx_nextcloud_9x.html. Everything is working except /index.php/… requests. They results in a 404.

For example if I want to change a users quota I got a 404 in the dev tools (POST /index.php/settings/ajax/setquota.php 404 ()).
The same happened when I want to update an app (POST /index.php/settings/ajax/updateapp.php 404 ())

The corresponding nginx directive:

location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {
    include /etc/nginx/fastcgi_params;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    fastcgi_param SCRIPT_FILENAME {DOCROOT}$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param HTTPS $https;
    fastcgi_param modHeadersAvailable true;
    fastcgi_param front_controller_active true;
    {FASTCGIPASS}
    fastcgi_intercept_errors on;
    fastcgi_request_buffering off;
}

Info: {DOCROOT} and {FASTCGIPASS} will be replaced to the correct settings by ispconfig.

Do you have an idea how to resolve the 404 responses?

=== EDIT #1 ===
Requests to /remote.php/dav/files/… works. I think this request belongs to the same nginx directive. Maybe the nginx directive is not the reason for the 404 errors on the /index.php/ requests.

=== EDIT #2 :wink: ===
I’m back to narrow the 404 issue. Now I find out using /index.php/settings/admin instead of /settings/admin makes no difference. Both urls leads me to the general admin page. So as I said in edit #1 the nginx location directive is not the reason for the 404 when changing a users quota.

For now following requests results in a 404:

  • /index.php/apps/files/ajax/getstoragestats.php?dir=%2F (results in not being able to uploads files)
  • /index.php/settings/ajax/updateapp.php
  • /index.php/settings/ajax/disableapp.php
  • /index.php/settings/ajax/setquota.php

Changing the fastcgi_param “front_controller_active” to false and / or set “htaccess.IgnoreFrontController” to true (as mentioned in Nginx with subdir and chrooted php-fpm returns 404 errors for some (SVG) files) doesn’t work for me. Going back from pretty urls to default urls doesn’t work too.

Is there any solution for nc12 or do I have to wait for nc13 to get that issue solved as @MichaIng said in the linked thread?

Generally use the current admin manual: https://docs.nextcloud.com/server/12/admin_manual/installation/nginx.html
But there should be no difference @ nginx config.

Yes, the front_controller_active directive enables pretty URLs, so that /index.php/ does not appear within URL and URLs with it inside, might lead to error. At Apache this does not include remote.php, at least I didn’t change somehing in my (cal/card/web)dav client URLs. Not sure how this is with Nginx.

During my tests on Debian systems, the directive with Nginx leads to missing icons in Nextcloud web ui, but did not lead to URL errors. With NC13 Beta this was solved. So I would recommmend in question to just remove the line completely (as well as related lines in config.php), until NC13 release.

After such changes, some cache (especially browser) keep the old configs/partly, leading to mixed/unexpected behavior. So after adjusting as mentioned try to access with different browser first, or clear all caches. Server side this should be done by restarting nginx and php-fpm or whatever you use.

Looks like the problem is that the regex
^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/)
matches /index.php/[anything]/ but not /index.php/[anything].php, thus nginx doesn’t know where to route and returns 404.

My temporary fix is to separately route /index.php/settings/ajax/ using a prefix match (hack I know but it works and I don’t know much about nginx):

location ^~ /index.php/settings/ajax/ {
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        #return 200 $document_root$fastcgi_path_info;
        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-fpm;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
}