Starting store 5 on a Debian Jessie machine with nginx and php5-fpm , we often get 502 Bad Gateway . This happens mainly in the backend, where longer operations work like creating thumbnails, even if it runs in small pieces of single ajax requests.
The server used with 64 GB of RAM and 16 cores was generally asleep, because there was no real traffic on it. We use it as an intermediate system, unless we have fixed all errors like this.
Error Log:
In the nginx error log, the following lines can be found:
[error] 20524#0: *175 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xx.xx, server: domain.com, request: "POST /backend/MediaManager/createThumbnails HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.domain.com", referrer: "http://www.domain.com/backend/" [error] 20524#0: *175 no live upstreams while connecting to upstream, client: xx.xx.xx.xx, server: domain.com, request: "POST /backend/Log/createLog HTTP/1.1", upstream: "fastcgi://php-fpm", host: "www.domain.com", referrer: "http://www.domain.com/backend/" [error] 20524#0: *175 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xx.xx, server: domain.com, request: "GET /backend/login/getLoginStatus?_dc=1457014588680 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.domain.com", referrer: "http://www.domain.com/backend/" [error] 20522#0: *209 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xx.xx, server: domain.com, request: "GET /backend/login/getLoginStatus?_dc=1457014618682 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.domain.com", referrer: "http://www.domain.com/backend/"
Perhaps it is noteworthy that the error "* 175 connect first occurs, and then, finally, " * 209 connect .
Configuration files:
I will try to publish only significant lines related to this topic, and will not mark all those lines that are commented out.
PHP-FPM:
/etc/php5-fpm/pool.d/www.conf:
[www] user = www-data group = www-data listen = /var/run/php5-fpm.sock listen.owner = www-data listen.group = www-data pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3
Nginx:
/etc/nginx/nginx.conf:
user www-data; worker_processes auto; pid /run/nginx.pid; events { worker_connections 768; multi_accept on; } http {
/etc/nginx/sites-available/site.conf:
server { listen 80; listen 443 ssl; server_name xxxxxxxx.com; root /var/www/shopware; ## Access and error logs. access_log /var/log/nginx/xxxxxxxx.com.access.log; error_log /var/log/nginx/xxxxxxxx.com.error.log; ## leaving out lots of shopware/mediafiles-related settings ## .... ## continue: location ~ \.php$ { try_files $uri $uri/ =404; ## NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini fastcgi_split_path_info ^(.+\.php)(/.+)$; ## required for upstream keepalive # disabled due to failed connections #fastcgi_keep_conn on; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SHOPWARE_ENV $shopware_env if_not_empty; fastcgi_param ENV $shopware_env if_not_empty; # BC for older SW versions fastcgi_buffers 8 16k; fastcgi_buffer_size 32k; client_max_body_size 24M; client_body_buffer_size 128k; ## upstream "php-fpm" must be configured in http context fastcgi_pass php-fpm; } }
So what's now? Please allow me now if I have to provide additional information on this.
Update
After applying nginx and fpm settings from @peixotorms, errors in nginx logs changed to:
30 upstream timed out (110: Connection timed out) while reading response header from upstream
But the problem itself has not been resolved. He just has a different face ...