Ошибка “504 Gateway Time-out” при обновлении NextCloud до 19 версии

Задача:
---------------------------------------------------------------Найти причину возникновения ошибки “Parsing response failed. 504 Gateway Time-out” при попытке обновить NextCloud до новой версии и сделать необходимые настройки сервера.
При попытке обновить NextCloud с версии 18 до 19.0.3 возникла ошибка
Create backup
Parsing response failed. <html><head><title>504 Gateway Time-Out</title></head><body><center><h1>504 Gateway Time-Out</h1></center><hr><center>nginx/1.18.0</center></body></html>
Так выглядит в браузере

В процессе поиска ошибки добавилась ошибка ImageMagick
root@cloud:/ # php -v PHP Warning: Version warning: Imagick was compiled against ImageMagick version 1690 but version 1691 is loaded. Imagick will run but may behave surprisingly in Unknown on line 0 PHP 7.3.22 (cli) (built: Sep 17 2020 01:30:59) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.22, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.22, Copyright (c) 1999-2018, by Zend Technologies root@cloud:/ #
Решается просто обновлением или установкой нужной версии pecl-imagick. Проверяем доступные для установки
root@cloud:/ # pkg search pecl-imagick php72-pecl-imagick-3.4.4 PHP wrapper to the ImageMagick/GraphicsMagick library version 6 php72-pecl-imagick-im7-3.4.4 PHP wrapper to the ImageMagick/GraphicsMagick library version 7 php73-pecl-imagick-3.4.4 PHP wrapper to the ImageMagick/GraphicsMagick library version 6 php73-pecl-imagick-im7-3.4.4 PHP wrapper to the ImageMagick/GraphicsMagick library version 7 php74-pecl-imagick-3.4.4 PHP wrapper to the ImageMagick/GraphicsMagick library version 6 php74-pecl-imagick-im7-3.4.4 PHP wrapper to the ImageMagick/GraphicsMagick library version 7 root@cloud:/ #
Устанавливаем соответствующую версию для PHP 7.3
root@cloud:/ # pkg install php73-pecl-imagick-im7 Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 2 package(s) will be affected (of 0 checked): New packages to be INSTALLED: ImageMagick7-nox11: 7.0.10.24 php73-pecl-imagick-im7: 3.4.4 Number of packages to be installed: 2 The process will require 26 MiB more space. 87 KiB to be downloaded. Proceed with this action? [y/N]: y [1/1] Fetching php73-pecl-imagick-im7-3.4.4.txz: 100% 87 KiB 89.3kB/s 00:01 Checking integrity... done (3 conflicting) - php73-pecl-imagick-im7-3.4.4 conflicts with php73-pecl-imagick-3.4.4 on /usr/local/lib/php/20180731/imagick.so - ImageMagick7-nox11-7.0.10.24 conflicts with ImageMagick6-nox11-6.9.11.6,1 on /usr/local/bin/Magick++-config - ImageMagick7-nox11-7.0.10.24 conflicts with ImageMagick6-nox11-6.9.11.6,1 on /usr/local/bin/Magick++-config Checking integrity... done (0 conflicting) Conflicts with the existing packages have been found. One more solver iteration is needed to resolve them. The following 4 package(s) will be affected (of 0 checked): Installed packages to be REMOVED: ImageMagick6-nox11: 6.9.11.6,1 php73-pecl-imagick: 3.4.4 New packages to be INSTALLED: ImageMagick7-nox11: 7.0.10.24 php73-pecl-imagick-im7: 3.4.4 Number of packages to be removed: 2 Number of packages to be installed: 2 Proceed with this action? [y/N]: y [1/4] Deinstalling php73-pecl-imagick-3.4.4... [1/4] Deleting files for php73-pecl-imagick-3.4.4: 100% [2/4] Deinstalling ImageMagick6-nox11-6.9.11.6,1... [2/4] Deleting files for ImageMagick6-nox11-6.9.11.6,1: 100% [3/4] Installing ImageMagick7-nox11-7.0.10.24... [3/4] Extracting ImageMagick7-nox11-7.0.10.24: 100% [4/4] Installing php73-pecl-imagick-im7-3.4.4... [4/4] Extracting php73-pecl-imagick-im7-3.4.4: 100% ===== Message from php73-pecl-imagick-im7-3.4.4: -- This file has been added to automatically load the installed extension: /usr/local/etc/php/ext-20-imagick.ini root@cloud:/ # php -v PHP 7.3.22 (cli) (built: Sep 17 2020 01:30:59) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.22, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.22, Copyright (c) 1999-2018, by Zend Technologies root@cloud:/ #
Для решения основной ошибки, проверяем хватает ли ресурсов серверу. Об этом читаем тут: “Ошибка “504 Gateway Time-out” при обновлении nextcloud” если у вас используется связка nginx, php-fpm и apache, то вы используете nginx как прокси сервер и вам необходимо добавить:
proxy_connect_timeout 600; proxy_send_timeout 600; proxy_read_timeout 600; send_timeout 600;
Если у вас только nginx, то вы его используете как веб-сервер. В этом случае
fastcgi_read_timeout 300;
Для примера, мой конфиг:
root@cloud:/ # cat /usr/local/etc/nginx/nginx.conf worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; upstream php-handler { #server 127.0.0.1:9000; server unix:/var/run/php-fpm.sock; } server { # server_name nc.local; # server_name _; server_name cloud.osbsd.net; # return 301 https://$server_name$request_uri; add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;"; add_header X-Content-Type-Options nosniff; 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; add_header Referrer-Policy no-referrer; add_header X-Frame-Options "SAMEORIGIN"; fastcgi_hide_header X-Powered-By; root /usr/local/www/nextcloud/; location ~ /.well-known { location ~ /.well-known/acme-challenge/(.*) { default_type "text/plain"; root /usr/local/www/letsencrypt; } } location = /robots.txt { allow all; log_not_found off; access_log off; } location = /.well-known/carddav { return 301 $scheme://$host/remote.php/dav; } location = /.well-known/caldav { return 301 $scheme://$host/remote.php/dav; } client_max_body_size 512M; fastcgi_buffers 64 4K; 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; location / { rewrite ^ /index.php$request_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\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) { fastcgi_split_path_info ^(.+?\.php)(\/.*|)$; include fastcgi_params; 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-handler; fastcgi_intercept_errors on; fastcgi_request_buffering off; fastcgi_read_timeout 300; } location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) { try_files $uri/ =404; index index.php; } location ~ \.(?:css|js|woff2?|svg|gif)$ { try_files $uri /index.php$request_uri; add_header Cache-Control "public, max-age=15778463"; add_header X-Content-Type-Options nosniff; 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; add_header Referrer-Policy no-referrer; add_header X-Frame-Options "SAMEORIGIN"; access_log off; } location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ { try_files $uri /index.php$request_uri; access_log off; } listen [::]:443 ssl ipv6only=on; # managed by Certbot listen 443 ssl; # managed by Certbot ssl_certificate /usr/local/etc/letsencrypt/live/cloud.osbsd.net/fullchain.pem; # managed by Certbot ssl_certificate_key /usr/local/etc/letsencrypt/live/cloud.osbsd.net/privkey.pem; # managed by Certbot include /usr/local/etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /usr/local/etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot } server { listen 443 ssl http2; listen [::]:443 ssl http2; # server_name nc.local; # server_name _; server_name cloud.osbsd.net; ssl_certificate /etc/ssl/nc.local.crt; ssl_certificate_key /etc/ssl/nc.local.key; # ssl_certificate /usr/local/etc/letsencrypt/live/cloud.osbsd.net/fullchain.pem; # ssl_certificate_key /usr/local/etc/letsencrypt/live/cloud.osbsd.net/privkey.pem; add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;"; add_header X-Content-Type-Options nosniff; 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; add_header Referrer-Policy no-referrer; add_header X-Frame-Options "SAMEORIGIN"; fastcgi_hide_header X-Powered-By; root /usr/local/www/nextcloud/; location ~ /.well-known { location ~ /.well-known/acme-challenge/(.*) { default_type "text/plain"; root /usr/local/www/letsencrypt; } } location = /robots.txt { allow all; log_not_found off; access_log off; } location = /.well-known/carddav { return 301 $scheme://$host/remote.php/dav; } location = /.well-known/caldav { return 301 $scheme://$host/remote.php/dav; } client_max_body_size 512M; fastcgi_buffers 64 4K; 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; location / { rewrite ^ /index.php$request_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\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) { fastcgi_split_path_info ^(.+?\.php)(\/.*|)$; include fastcgi_params; 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-handler; fastcgi_intercept_errors on; fastcgi_request_buffering off; fastcgi_read_timeout 300; } location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) { try_files $uri/ =404; index index.php; } location ~ \.(?:css|js|woff2?|svg|gif)$ { try_files $uri /index.php$request_uri; add_header Cache-Control "public, max-age=15778463"; add_header X-Content-Type-Options nosniff; 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; add_header Referrer-Policy no-referrer; add_header X-Frame-Options "SAMEORIGIN"; access_log off; } location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ { try_files $uri /index.php$request_uri; access_log off; } } server { if ($host = cloud.osbsd.net) { return 301 https://$host$request_uri; } # managed by Certbot listen 80; listen [::]:80; server_name cloud.osbsd.net; return 404; # managed by Certbot }}
не забываем перезапустить nginx
nginx -s reload
1 комментарий
[…] Решение с ImageMagick (imagick): “Ошибка “504 Gateway Time-out” при обновлении NextCloud до 19 версии“ […]