上游超时(110:连接超时),同时从上游读取响应头,客户端:66.38.32.24,服务器:xxxx.com,请求:

时间:2017-05-22 16:43:34

标签: php nginx

我的服务器经常出现超时问题,我调整了fastcg_read_timeoutproxy_read_timeout等参数,但这并没有解决我的问题。在下面找到我的xxxx.conf

server {
server_name www.xxxx.com;
return 301 $scheme://xxxx.com$request_uri;
}

server {
    ## Your website name goes here.
    server_name xxxx.com;

    ## Your only path reference.
    root /var/www/xxxx.com;


 # This should be in your http block and if it is, it's not needed here.
    index index.html index.php;

    error_log    /var/log/nginx/xxxx.com-error.log;
    access_log   /var/log/nginx/xxxx.com-access.log;


    # Body size (max upload)
    #    client_max_body_size 64m;
    #    client_body_buffer_size 2m;



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

    # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
    # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
    location ~ /\. {
        deny all;
    }

    # Deny access to any files with a .php extension in the uploads directory
    # Works in sub-directory installs and also in multisite network
    # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
    location ~* /(?:uploads|files)/.*\.php$ {
        deny all;
    }

    location / {
            # This is cool because no php is touched for static content
            try_files $uri $uri/ /index.php?$args;
            # This to stop connection timeout
            proxy_http_version 1.1;
            proxy_set_header Connection "";
           # Time-out Settings
            proxy_send_timeout   150;
            proxy_read_timeout   150;
    }


    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5-fpm-sock;
            fastcgi_read_timeout 150;
            fastcgi_index index.php;
            include fastcgi_params;
    }


    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            expires max;
            log_not_found off;
    }}

2 个答案:

答案 0 :(得分:0)

我在本地nginx机器上进行开发时遇到了同样的问题。

经过一番广泛的研究后,我找到了解决问题的方法(不幸的是我再找不到这篇文章)。

您可以尝试更改此内容:

fastcgi_pass_unix: localhost:9000;

然后运行'sudo service nginx reload'。

这解决了我的问题。希望它也适合你。

答案 1 :(得分:0)

这个问题已经解决了。我对proxy_send_timeout和proxy_read_timeout以及fastcgi_read_timeout进行了评论,但在下面的代码中留下了proxy_http_version和proxy_set_header。

 location / {

        proxy_http_version 1.1;
        proxy_set_header Connection "";

      #  proxy_send_timeout   150;
      #  proxy_read_timeout   150;
}