Users cannot login via webinterface after upgrade from owncloud 8.2.10 to nextcloud 9.0.57

Nextcloud version (eg, 10.0.2): 9.0.57
Operating system and version (eg, Ubuntu 16.04): Ubuntu 16.04.2 LTS
Apache or nginx version (eg, Apache 2.4.25): nginx 1.10.0
PHP version (eg, 5.6): php7.0-fpm 7.0.17
Is this the first time you’ve seen this error?: No, I run into this error every time I try to upgrade from ownCloud 8.2.10 to nextcloud 9.0.57 or ownCloud 9.0.8.

Can you reliably replicate it? (If so, please outline steps):

  1. Upgrade to nextcloud 9.0.57 via occ upgrade command
  2. Wait until the upgrade finished successfully
  3. Edit nginx vHost file following the examples in Nextcloud 9 Server Administration Manual
  4. Restart php7.0-fpm and nginx
  5. Try to login with any existing user account to the webinterface
  6. Got an “504 Gateway Time-out”

The issue you are facing:
Can not log in to the webinterface as any existing user. Got “504 Gateway Time-out” error.

The output of your Nextcloud log in Admin > Logging:
Could not catch that log because I could not log in.

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

<?php
$CONFIG = array (
  'trusted_domains' =>
  array (
    0 => 'nc.my-it-brain.de',
  ),
  'dbtype' => 'mysql',
  'version' => '9.0.57.2',
  'dbhost' => 'localhost',
  'dbtableprefix' => 'oc_',
  'installed' => true,
  'forcessl' => true,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_from_address' => 'owncloud',
  'mail_domain' => 'my-it-brain.de',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'loglevel' => '3',
  'theme' => '',
  'maintenance' => false,
  'trashbin_retention_obligation' => 'auto',
  'updater.release.channel' => 'stable',
);

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

2017/04/11 19:01:45 [error] 7538#7538: *27723 upstream timed out (110: Connection timed out) while reading response header from upstream, client: XXX.XXX.XXX.XXX, server: nc.my-it-brain.de, request: "POST / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9200", host: "nc.my-it-brain.de"

Here is my vHost configuration file for nextcloud:

## BEGIN NEXTCLOUD CONFIGURATION ###############################################

upstream nc-php-handler {
    server 127.0.0.1:9200;
}

server {
        listen 80;
        listen [::]:80;
        server_name nc.my-it-brain.de;

        return 301 https://$server_name$request_uri; # enforce https
}

server {
    # Listen on Port 443
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name nc.my-it-brain.de;

    ssl_certificate /path/to/crt;
    ssl_certificate_key /path/to/key;

    ssl_ciphers 'some ciphers';
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/nginx/dh_params.pem;

        # Add headers to serve security related headers
        # add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
        add_header X-Content-Type-Options nosniff;
        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Robots-Tag none;
        add_header X-Download-Options noopen;
        add_header X-Permitted-Cross-Domain-Policies none;

    # Path to the root of your installation
    root /path/to/$host/nextcloud;

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

    # Path to the logfiles
    access_log /path/to/nginx_access.log combined;
    error_log /path/to/nginx_error.log error;

    # Standardconfiguration from owncloud.org following
    # set max upload size
    client_max_body_size 10G;
    fastcgi_buffers 64 4K;

    # Disable gzip to avoid the removal of the ETag header
    gzip off;

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

    # The following 2 rules are only needed with webfinger
    rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
    rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;

    location = /.well-known/carddav {
        return 301 $scheme://$host/remote.php/dav;
    }

    location = /.well-known/caldav {
        return 301 $scheme://$host/remote.php/dav;
    }

    location / {
        rewrite ^ /index.php$uri;
    }

    location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
        deny all;
    }

    location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
        deny all;
    }

    location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {
        include fastcgi_params;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        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_read_timeout 120;
        fastcgi_pass nc-php-handler;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
    }

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

    # Adding the cache control header for js and css files
    # Make sure it is BELOW the location ~ \.php(?:$|/) { block
    location ~* \.(?:css|js)$ {
        add_header Cache-Control "public, max-age=7200";
        # 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;";
        add_header X-Content-Type-Options nosniff;
        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Robots-Tag none;
        # Optional: Don't log access to assets
        access_log off;
    }
    # Optional: set long EXPIRES header on static assets
    location ~* ^.+\.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
        try_files $uri /index.php$uri$is_args$args;
        # Optional: Don't log access to assets
         access_log off;
    }
}
## END NEXTCLOUD CONFIGURATION #################################################

I really got stuck on this. I could not find any mistake in the vhost configuration file. When I try to login I only got the error in nginx error log. There is no entry in the php7.0-fpm.log. I don’t know what’s wrong here, I just could not see it.

Any help would be appreciated.

Kind regards,
Tronde

Edit: I filed the issue 4081 on GitHub, but I’m not certain if this is a bug or a layer 8 issue.

Sorry for pushing this. But my instance is in non operational state since three days and I could not figure out what’s wrong here. :disappointed: :worried:

Could anyone help, please? How could I troubleshoot this issue to provide more information relevant for fixing this issue?

I’m using Apache but I’ll take a stab. Has something changed with how php-fpm is listening as described in this similar situation: https://blog.dbrgn.ch/2013/5/25/php-fpm-connection-refused/?

I see you are using php-7. Try running:
grep -ri "listen = " /etc/php7.0/fpm

If you see something like:
/etc/php/7.0/fpm/pool.d/www.conf:listen = /run/php/php7.0-fpm.sock

If that’s the case you need to change:
server 127.0.0.1:9200
to
server unix:/run/php/php7.0-fpm.sock

If that doesn’t work try contacting https://github.com/josh4trunks. He is identified as the contributor for the Nextcloud Nginx config files.

Hi,

My php setup did not changed since using php7.0-fpm for ownCloud 8.2.10. I’m not using unix sockets but tcp socket instead:

:~$ sudo grep -ri "listen = " /etc/php/7.0/fpm
/etc/php/7.0/fpm/pool.d/jkastning.conf:listen = 127.0.0.1:9200

And there is a process listening on this port:

:~$ sudo netstat -tlpen | grep 9200
tcp        0      0 127.0.0.1:9200          0.0.0.0:*               LISTEN      0          20084       1309/php-fpm.conf)

Beyond seeking out josh4trunks or waiting for more replies you can see if you get any ideas from this article: https://medium.com/@richb_/tweaking-nginx-and-php-fpm-configuration-to-fix-502-bad-gateway-errors-and-optimise-performance-on-17465f41fd87

Other than that? I’m wondering if paid support could help you migrate your users and data to Nextcloud 11 but I’m not sure if Nginx is “officially” supported.

Unfortunately I had no luck with the article.

Nginx is not offically supported in Nextcloud 9 or any other version including 11. Maybe that changes in version 12, but I don’t know that for sure.

I will try to contact josh4trunks somehow and wait if here is anybody else who could help.

Hello,

the mystery is solved. Instead of figuring out what’s wrong with the version 9.0.57 I went further on with the migration until I ended up with a successful installation of nextcloud 11.0.2.

The users where still able to login again in version 10 and were still able to do it in version 11.0.2.

You could find the whole story of troubleshooting here at github.

Thanks,
Tronde