Nginx is downloading the index.php of my second nextcloud instance

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version: 22.2.2
Operating system and version : Debian 11
Nginx version: 1.18.0
PHP version: 7.4.25

The issue you are facing:
For sure nothing to do with NC but I can’t find what is wrong. I’m trying to get the second NC instance on anotehr domain running. First NC is running well. Below if the Nginx config of the second instance. Instead of opening index.php (e.g. teh setup) browser is just trying to download the index page. I tries different browser and devices.

 1 server {
 2     listen 80;
 3     listen [::]:80;
 4     server_name cloud.example.net;
 5     return 301 https://$server_name:443$request_uri;
 6 }
 7
 8 server {
 9     listen 443 ssl http2;
10     listen [::]:443 ssl http2;
11     server_name cloud.example.net;
12     root /var/www/nextcloudst;
13     index index.php index.html index.htm;
14
15     ssl_certificate /etc/letsencrypt/live/cloud.example.net/fullchain.pem;
16     ssl_certificate_key /etc/letsencrypt/live/cloud.example.net/privkey.pem;
17
18     ssl_dhparam /etc/nginx/ssl/dhparams.pem;
19 #    ssl_trusted_certificate /etc/letsencrypt/cloud.example.net/ca.pem;
20     ssl_protocols TLSv1.2 TLSv1.3;
21     ssl_ciphers 'TLS-CHACHA20-POLY1305-SHA256:TLS-AES-256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA>
22     ssl_ecdh_curve secp521r1:secp384r1;
23     ssl_prefer_server_ciphers on;
24     ssl_stapling on;
25     ssl_stapling_verify on;
26     ssl_session_timeout 24h;
27 #    ssl_session_cache shared:SSL:50m;
28     ssl_session_tickets off;
29
30     add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
31     add_header Referrer-Policy "no-referrer" always;
32     add_header X-Content-Type-Options "nosniff" always;
33     add_header X-Download-Options "noopen" always;
34     add_header X-Frame-Options "SAMEORIGIN" always;
35     add_header X-Permitted-Cross-Domain-Policies "none" always;
36     add_header X-Robots-Tag "none" always;
37     add_header X-XSS-Protection "1; mode=block" always;
38
39     fastcgi_hide_header X-Powered-By;
40
41     access_log off;
42
43   location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {
44         try_files $uri /index.php$request_uri;
45         # Optional: Don't log access to other assets
46         access_log off;
47     }
48
49     location /.well-known/carddav {
50             return 301 $scheme://$host/remote.php/dav;
51     }
52
53     location /.well-known/caldav {
54             return 301 $scheme://$host/remote.php/dav;
55     }
56
57     rewrite ^/.well-known/webfinger /index.php$uri redirect;
58     rewrite ^/.well-known/nodeinfo /index.php$uri redirect;
59 }

Is this the first time you’ve seen this error?: Y

Steps to replicate it:

  1. Intstall second nextcloud instance
  2. Copy settings from old instance
  3. Try to open the domain

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'ocuic1candoc',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'default_phone_region' => 'DE',
  'passwordsalt' => 'XXX',
  'secret' => 'XXX',
  'allow_local_remote_servers' => true,
  'trusted_domains' =>
  array (
    0 => 'cloud.example.net',
    1 => 'office.example.net',
  ),
  'onlyoffice' =>
  array (
    'verify_peer_off' => true,
    'jwt_header' => 'Authorization',
    'jwt_secret' => 'XXX',
  ),
  'datadirectory' => '/media/cloud',
  'dbtype' => 'mysql',
  'version' => '22.2.2.0',
  'overwrite.cli.url' => 'https://cloud.example.net',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'XXX',
  'dbpassword' => 'XXX',
  'installed' => true,
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
);

After I added this to nginx config and deleted the old config.php the setup run once, also the update to 22.2 but dashboard results into 404.

Any ideas?

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}