【问题标题】:Nginx server : upstream timed out (10060: A connection attempt failed)Nginx 服务器:上游超时(10060:连接尝试失败)
【发布时间】:2015-05-26 00:18:29
【问题描述】:

我们正在运行一项服务,它将问题从 Jira 迁移到测试链接。所以我使用 nginx 服务器与 mysql 数据库通信并在浏览器中运行测试链接。

当我导入更多没有问题时,nginx 服务器突然自动关闭。我在 Windows server 2008 R2 标准和 64 位操作系统中运行我的服务和 nginx 服务器。 我检查了C:\nginx\logs中的error.log文件,发现错误为

upstream超时(10060:连接尝试失败,因为连接的一方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机没有响应)连接到upstream,client:192.168.27.151,服务器:本地主机,请求:“GET /testlink/lib/general/frmWorkArea.php?feature=reqSpecMgmt HTTP/1.1”,上游:“fastcgi://127.0.0.1:9000”,主机:“wo-qatestlink01”,推荐人: "http://wo-qatestlink01/testlink/lib/general/navBar.php?tproject_id=0&tplan_id=0&updateMainPage=1"

谢谢。

日志文件

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    proxy_read_timeout 600; 

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index index.php;
        fastcgi_read_timeout 600;
            #The above line has been added and below line has been commented to use the php code.
            #index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #   proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        ########## Code added during Configuration By Anthony ################
        location ~ \.php$ {
        root           html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  c:/nginx/html/$fastcgi_script_name;
        include        fastcgi_params;
        }
        ######################################################################
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

【问题讨论】:

  • 清理格式
  • 您需要提供更多信息,例如 nginx.conf 内容、端口 9000 上运行的内容以及您的 fcgi 使用哪些参数启动,上游处理通用请求需要多长时间...
  • 检查时间(out)值,例如 client_body_timeout、client_header_timeout、keepalive_timeout、send_timeout、keepalive_requests。以及 conf/fastcgi_params 中的值。 “因为连接方在一段时间后没有正确响应”。多久会发生此超时?

标签: php mysql nginx


【解决方案1】:

这个问题是由于 nginx 在从后端 (php) 获得响应之前超时。在 nginx 中设置了一些超时来改变这一点。

fastcgi 的默认“响应”超时为 60 秒。你有它在 600 年代,这可能没有足够的时间。

fastcgi_read_timeout 60s; 

Nginx Documentation : FastCGI Module

【讨论】:

    【解决方案2】:

    在我的例子中,我在 FreeBSD Jail(Nginx 1.6.2,PHP/5.6.6)中使用 TCP-Port 而不是套接字运行我的服务器。问题解决了更改我的两个设置

    php-fpm.conf

    文件:

    ;listen.allowed_clients = 127.0.0.1 # comment out to listen to any
    listen = 9000 # No IP-Address
    

    成功了。

    【讨论】:

      猜你喜欢
      • 2016-12-07
      • 1970-01-01
      • 1970-01-01
      • 2010-10-27
      • 1970-01-01
      • 1970-01-01
      • 2014-03-01
      • 1970-01-01
      • 2011-08-01
      相关资源
      最近更新 更多