5

nginxphp5- fpm を使用して Debian Jessie マシンでショップウェア 5 を実行すると、非常に頻繁に502 Bad Gatewayが発生します。これは主にバックエンドで発生し、たとえこれが単一の ajax リクエストの小さなチャンク内で行われたとしても、サムネイルの作成などの長い操作が行われている場合に発生します。

実際のトラフィックがないため、64 GB RAM と 16 コアの使用済みサーバーはまったくスリープ状態です。このようなエラーをすべて修正しない限り、現在はステージング システムのように使用しています。

エラーログ:

nginx-error ログでは、次の行が見つかります。

[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/"

最初に多くの"*175 connect"エラーが発生し、最後に"*209 connect " エラーが発生することは注目に値するかもしれません。

構成ファイル:

このトピックに関連する重要な行のみを投稿し、コメント アウトされている行はすべて除外します。

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 {
    ## MIME types.
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ## Default log and error files.
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ## Use sendfile() syscall to speed up I/O operations and speed up
    ## static file serving.
    sendfile        on;

    ## Handling of IPs in proxied and load balancing situations.
    # set_real_ip_from        192.168.1.0/24; # set to your proxies ip or range
    # real_ip_header          X-Forwarded-For;

    ## Timeouts.
    client_body_timeout             60;
    client_header_timeout           60;
    keepalive_timeout            10 10;
    send_timeout                    60;

    ## Reset lingering timed out connections. Deflect DDoS.
    reset_timedout_connection on;

    ## Body size.
    client_max_body_size 10m;

    ## TCP options.
    tcp_nodelay        on;
    ## Optimization of socket handling when using sendfile.
    tcp_nopush         on;

    ## Compression.
    gzip              on;
    gzip_buffers      16 8k;
    gzip_comp_level   1;
    gzip_http_version 1.1;
    gzip_min_length   10;
    gzip_types        text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon application/vnd.ms-fontobject font/opentype application/x-font-ttf;
    gzip_vary         on;
    gzip_proxied      any; # Compression for all requests.
    gzip_disable      "msie6";

    ## Hide the Nginx version number.
    server_tokens off;

    ## Upstream to abstract backend connection(s) for PHP.
    upstream php-fpm {
        server unix:/var/run/php5-fpm.sock;
        # server 127.0.0.1:9000;

        ## Create a backend connection cache.
        keepalive 32;
    }

    ## Include additional configs
    include /etc/nginx/conf.d/*.conf;

    ## Include all vhosts.
    include /etc/nginx/sites-enabled/*;
}

/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;
    }

}

今何をする?この質問にさらに情報を提供する必要がある場合は、今すぐお知らせください。

アップデート

@peixotorms から nginx- および fpm-settings を適用した後、nginx-logs のエラーは次のように変わりました。

30 upstream timed out (110: Connection timed out) while reading response header from upstream

しかし、問題自体は解決していません。もう一面しかない…。

4

2 に答える 2