Issue: Upgrading to Nextcloud 18.0, updater results in 404. Running in FreeNAS jail

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 (eg, 12.0.2): 17.0.2 (using FreeNAS addon)
Operating system and version (eg, Ubuntu 17.04): FreeNAS Jail running FreeNAS 11.2
Apache or nginx version (eg, Apache 2.4.25): nginx 1.14.0
PHP version (eg, 7.1): 7.1.33

The issue you are facing: 404 Not Found error when clicking the “Open updater” button

Is this the first time you’ve seen this error? (Y/N):

Steps to replicate it:

  1. Have nextcloud in its own Freenas jail, behind an Nginx virtual proxy. Nginx is installed in Ubuntu (IP: 192.168.1.119)
  2. Use the default Nginx config file, but comment out anything having to do with php as you can’t figure out how to reference it properly.
  3. Click “Update” in Nextcloud (IP: 192.168.1.137) admin settings.
  4. Get 404 page.

The output of your Nextcloud log in Admin > Logging:

Error	PHP	A non-numeric value encountered at /usr/local/www/nextcloud/apps/serverinfo/lib/OperatingSystems/DefaultOs.php#52	
2020-03-13T21:45:49-0400
Error	PHP	Invalid argument supplied for foreach() at /usr/local/www/nextcloud/apps/joplin/lib/Service/JoplinService.php#128	
2020-03-12T22:23:11-0400
Error	PHP	Undefined index: jsFiles at /usr/local/www/nextcloud/apps/joplin/lib/Service/JoplinService.php#128	
2020-03-12T22:23:11-0400
Error	PHP	Invalid argument supplied for foreach() at /usr/local/www/nextcloud/apps/joplin/lib/Service/JoplinService.php#128	
2020-03-12T22:10:01-0400
Error	PHP	Undefined index: jsFiles at /usr/local/www/nextcloud/apps/joplin/lib/Service/JoplinService.php#128	
2020-03-12T22:10:01-0400
Error	PHP	A non-numeric value encountered at /usr/local/www/nextcloud/apps/serverinfo/lib/OperatingSystems/DefaultOs.php#52	
2020-03-12T22:09:42-0400
Error	PHP	Invalid argument supplied for foreach() at /usr/local/www/nextcloud/apps/joplin/lib/Service/JoplinService.php#128	
2020-03-12T22:05:47-0400
Error	PHP	Undefined index: jsFiles at /usr/local/www/nextcloud/apps/joplin/lib/Service/JoplinService.php#128	
2020-03-12T22:05:47-0400
Error	PHP	Undefined index: appt_pps at /usr/local/www/nextcloud/apps/appointments/templates/public/form.php#14	
2020-03-12T22:05:36-0400
Error	PHP	Undefined index: appt_pps at /usr/local/www/nextcloud/apps/appointments/templates/public/form.php#14	
2020-03-12T22:05:24-0400
Error	no app in context	Exception: Repair step 'OCA\Appointments\InstallHook' is not of type \OCP\Migration\IRepairStep	
2020-03-12T21:59:00-0400

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

<?php
$CONFIG = array (
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/usr/local/www/nextcloud/apps',
      'url' => '/apps',
      'writable' => true,
    ),
    1 =>
    array (
      'path' => '/usr/local/www/nextcloud/apps-pkg',
      'url' => '/apps-pkg',
      'writable' => true,
    ),
  ),
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'instanceid' => REDACTED,
  'passwordsalt' => REDACTED,
  'secret' => REDACTED,
  'trusted_domains' =>
  array (
    0 => REDACTED,
    1 => REDACTED,
    2 => REDACTED,
    3 => '192.168.1.137',
  ),
  'datadirectory' => '/usr/local/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '17.0.2.1',
  'overwrite.cli.url' => REDACTED,
  'overwriteprotocol' => 'https',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => REDACTED,
  'dbpassword' => REDACTED,
  'installed' => true,
  'trusted_proxies' =>
  array (
    0 => '192.168.1.245',
    1 => '192.168.1.119',
  ),
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'nextcloud',
  'mail_domain' =>REDACTED,
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'smtp.gmail.com',
  'mail_smtpport' => '465',
  'mail_smtpname' =>REDACTED,
  'mail_smtppassword' =>REDACTED,
  'updater.secret' =>REDACTED,
);

I am 99% sure this below is the problem, as I can’t find how to set up the php-handler.

  • Nextcloud is in its own jail, installed using the Nextcloud plugin on FreeNAS
  • Nginx is on a VM, in Ubuntu 18.04. It acts as a reverse proxy, sorting through my requests and rerouting to various apps (wordpress, bitwarden, plex, nextcloud, etc.)
  • I’m not sure how to make Nextcloud and Nginx play nice together. This is an ongoing issue, and since Nextcloud works fine (with the exception of uploading images) I just ignored the issue. But now I can’t upgrade.

The output of your Apache/nginx/system log in /var/log/____:

## Required for line 101-117 ##
#upstream php-handler {
#	#server 127.0.0.1:9000;
#    server unix:/var/run/nextcloud-php-fpm.sock;
#}

server {
    server_name nextcloud.REDACTED;
    # The internal IP of the VM that hosts your Apache config
    set $upstream 192.168.1.137;
	# Add headers to serve security related headers
    # Before enabling Strict-Transport-Security headers please read into this
    # topic first.
    add_header Strict-Transport-Security "max-age=15768000; includeSubDomains;" always;
    #
    # WARNING: Only add the preload option once you read about
    # the consequences in https://hstspreload.org/. This option
    # will add the domain to a hardcoded list that is shipped
    # in all major browsers and getting removed from this list
    # could take several months.
    
    add_header Referrer-Policy "no-referrer" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Download-Options "noopen" always;
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Permitted-Cross-Domain-Policies "none" always;
    add_header X-Robots-Tag "none" always;
    add_header X-XSS-Protection "1; mode=block" always;
    
#I found this header is needed on Ubuntu, but not on Arch Linux. 
    #add_header X-Frame-Options "SAMEORIGIN";

# Remove X-Powered-By, which is an information leak
    fastcgi_hide_header X-Powered-By;

# To make reverse proxy work
    location / {
       proxy_pass_header Authorization;
       proxy_pass http://$upstream;
       proxy_set_header Host $host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_http_version 1.1;
       proxy_set_header Connection “”;
       proxy_buffering off;
       client_max_body_size 0;
       proxy_read_timeout 36000s;
       proxy_redirect off;
#       rewrite ^ /index.php; # This breaks nextcloud
    }
  
    access_log /var/log/nginx/nextcloud.access;
    error_log /var/log/nginx/nextcloud.error;

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    # The following 2 rules are only needed for the user_webfinger app.
    # Uncomment it if you're planning to use this app.
    #rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
    #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json
    # last;

    # The following rule is only needed for the Social app.
    # Uncomment it if you're planning to use this app.
    #rewrite ^/.well-known/webfinger /public.php?service=webfinger last;

    location = /.well-known/carddav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }
    location = /.well-known/caldav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }
    
    # set max upload size
    client_max_body_size 512M;
    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 ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
        deny all;
    }
    location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
        deny all;
    }

## This doesnt work cuz IDK how to set php-handler to 192.168.1.137 ##
#    location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.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 PATH_INFO $path_info;
#        fastcgi_param HTTPS on;
#        # Avoid sending the security headers twice
#        fastcgi_param modHeadersAvailable true;
#        # Enable pretty urls
#        fastcgi_param front_controller_active true;
#        fastcgi_pass php-handler;
#        fastcgi_intercept_errors on;
#        fastcgi_request_buffering off;
#    }

    location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
        try_files $uri/ =404;
        index index.php;
    }

## Breaks the login page if no php-handler ##
    # Adding the cache control header for js, css and map files
    # Make sure it is BELOW the PHP block
#    location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
#        try_files $uri /index.php$request_uri;
#        add_header Cache-Control "public, max-age=15778463";
        # Add headers to serve security related headers (It is intended to
        # have those duplicated to the ones above)
        # Before enabling Strict-Transport-Security headers please read into
        # this topic first.
        #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
        #
        # WARNING: Only add the preload option once you read about
        # the consequences in https://hstspreload.org/. This option
        # will add the domain to a hardcoded list that is shipped
        # in all major browsers and getting removed from this list
        # could take several months.
#        add_header Referrer-Policy "no-referrer" always;
#        add_header X-Content-Type-Options "nosniff" always;
#        add_header X-Download-Options "noopen" always;
#        add_header X-Frame-Options "SAMEORIGIN" always;
#        add_header X-Permitted-Cross-Domain-Policies "none" always;
#        add_header X-Robots-Tag "none" always;
#        add_header X-XSS-Protection "1; mode=block" always;

        # Optional: Don't log access to assets
#        access_log off;
#    }

    location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {
        try_files $uri /index.php$request_uri;
        # Optional: Don't log access to other assets
        access_log off;
    }


    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/russell.work/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/russell.work/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}


server {
    if ($host = nextcloud.REDACTED) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    server_name nextcloud.REDACTED;
    listen 80;
    return 404; # managed by Certbot


}