Nginx服务器:上游超时(10060:连接尝试失败)

时间:2015-03-23 03:44:08

标签: php mysql nginx

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

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

  

上游超时(10060:连接尝试失败,因为连接方在一段时间后未正确响应,或者由于连接主机未能响应而建立连接失败),同时连接到上游,客户端:192.168.27.151, server:localhost,request:“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;
    #    }
    #}

}

2 个答案:

答案 0 :(得分:0)

就我而言,我使用TCP-Port而不是socket在FreeBSD Jail( Nginx 1.6.2,PHP / 5.6.6 )中运行我的服务器。问题已解决,我在

中更改了两个设置
  

PHP-fpm.conf

文件:

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

有效。

答案 1 :(得分:0)

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

fastcgi的默认“响应”超时为60秒。你有600s,可能还不够。

fastcgi_read_timeout 60s; 

Nginx Documentation : FastCGI Module