Again 502 Ngix error

I have two containers with NextCloud. The first “production” one is based on MariaDB located in another container.
The second - for testing purposes - works based on a local built-in SQLite database.
The containers are based on Alpine Linux v3.17.

WEB server - Ngix 1.22.1.
PHP 7.4.33.
NextCloud ver 20.0.5

Everything worked fine, but after an update of the Alpine system (not NextCloud), the login page appears in the WEB interface of both instances, but after entering the user/pass, the following message appears:

502 Bad Gateway
nginx/1.22.1

NextCloud clients installed on Linux, WIN, iPad and Android systems work correctly (interestingly) both in the local network and remotely via the Internet.

I don’t know exactly after which update this happened, and I can’t say after installing which package this happened.
The problem is probably that some configuration files, their mods, permissions, etc. were overwritten during the update. Either in Ngix or in PHP.

I’m not very proficient in these things, so I’d like some help.

Below is the error that appears in the Ngix server log:

2023/05/19 12:55:38 [error] 652#652: *126 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.0.2, server: _, request: "POST /login HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.0.209"

Additional information that I managed to gather according to the instructions found on the Internet.


root@nc-test:/config/log/nginx# netstat -pltn | grep 9000
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      353/php-fpm.conf)
root@nc-test:/config/log/nginx# ps aux | grep php-fpm
root       346  0.0  0.0    204     0 pts/0    S+   May18   0:00 s6-supervise php-fpm
root       353  0.0  0.0 247284  5128 ?        Ss   May18   0:05 php-fpm: master process (/etc/php7/php-fpm.conf)
abc        378  0.0  0.3 252308 28748 ?        S    May18   0:02 php-fpm: pool www
abc        409  0.0  0.3 252272 29940 ?        S    May18   0:01 php-fpm: pool www
abc        900  0.0  0.0 247292  2764 ?        S    12:55   0:00 php-fpm: pool www
root       926  0.0  0.0   1608   768 pts/1    S+   13:22   0:00 grep php-fpm
root@nc-test:/config/www/nextcloud# cat config/config.php 
<?php
$CONFIG = array (
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'datadirectory' => '/data',
  'instanceid' => 'oczmnv2rty18',
  'passwordsalt' => 'xxxxxxxxxx',
  'secret' => 'yyyyyyyyy',
  'trusted_domains' => 
  array (
    0 => '192.168.0.209',
  ),
  'dbtype' => 'sqlite3',
  'version' => '19.0.3.1',
  'overwrite.cli.url' => 'https://192.168.0.209',
  'installed' => true,
);

Could someone help me solve the problem?
Will send all additional info ASAP on request.

What’s in your nextcloud.log during these failing transactions?

Login from Linux, Chrome browser.
When the login page appears, the following content is entered into nextcloud.log.

{"reqId":"P4ZIBZohswDSXJZTQGuP","level":3,"time":"2023-05-20T21:32:53+00:00","remoteAddr":"192.168.0.2","user":"--","app":"PHP","method":"GET","url":"/login","message":"PHP Startup: Unable to load dynamic library 'smbclient.so' (tried: /usr/lib/php7/modules/smbclient.so (Error relocating /usr/lib/php7/modules/smbclient.so: php_error_docref0: symbol not found), /usr/lib/php7/modules/smbclient.so.so (Error loading shared library /usr/lib/php7/modules/smbclient.so.so: No such file or directory)) at Unknown#0","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36","version":"19.0.3.1"}
{"reqId":"8iAR1lchdpSkGdS6hM2R","level":3,"time":"2023-05-20T21:32:54+00:00","remoteAddr":"192.168.0.2","user":"--","app":"PHP","method":"GET","url":"/apps/theming/js/theming?v=0","message":"PHP Startup: Unable to load dynamic library 'smbclient.so' (tried: /usr/lib/php7/modules/smbclient.so (Error relocating /usr/lib/php7/modules/smbclient.so: php_error_docref0: symbol not found), /usr/lib/php7/modules/smbclient.so.so (Error loading shared library /usr/lib/php7/modules/smbclient.so.so: No such file or directory)) at Unknown#0","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36","version":"19.0.3.1"}
{"reqId":"aMjoOd0EEiqLBTAJmY83","level":3,"time":"2023-05-20T21:32:54+00:00","remoteAddr":"192.168.0.2","user":"--","app":"PHP","method":"GET","url":"/apps/theming/styles?v=0","message":"PHP Startup: Unable to load dynamic library 'smbclient.so' (tried: /usr/lib/php7/modules/smbclient.so (Error relocating /usr/lib/php7/modules/smbclient.so: php_error_docref0: symbol not found), /usr/lib/php7/modules/smbclient.so.so (Error loading shared library /usr/lib/php7/modules/smbclient.so.so: No such file or directory)) at Unknown#0","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36","version":"19.0.3.1"}

Then when it shows:

502 Bad Gateway
nginx/1.22.1

nothing is added to this file.

The SMB library error occurs frequently but I am not using any SMB connection on any NextCloud instance.

Your PHP FPM php.ini (or a subdirectory loaded ini file possibly) has a reference to the PHP smbclient. You must either install it or remove the reference.

Presumably that OS update either removed it or upgraded PHP in such a way that it expected it.

The config line you’re looking for will be:

extension="smbclient.so"

The error with smbclient.so has always been present and has never interfered with the proper operation of the NC.
Interestingly, smbclient.so is installed.

root@nc-test:/# du -a 2>/dev/null |grep "smbclient.so"
0       ./usr/lib/libsmbclient.so.0
148     ./usr/lib/libsmbclient.so.0.7.0
248     ./usr/lib/php7/modules/smbclient.so

Anyway, this error occurs when the login page is displayed.
When trying to log in (using user/pass), no error is entered into the nextcloud.log but - as in the first post - in Ngix server log.

OK, SMB error removed by commenting line in file /etc/php7/conf.d/00_smbclient.ini

root@nc-test:/# cat /etc/php7/conf.d/00_smbclient.ini
#extension=smbclient.so

But the problem still exist…