读取上游 502 Bad GateWay 的响应标头时上游过早关闭连接

读取上游 502 Bad GateWay 的响应标头时上游过早关闭连接

nginx 正在杀死我..所以现在我遇到了 502 Bad Gateway。错误日志显示:

2016/10/12 17:39:53 [info] 3023#0: *464 client closed connection while waiting for request, client: 127.0.0.1, server: 0.0.0.0:443
2016/10/12 17:39:53 [info] 3023#0: *465 client closed connection while waiting for request, client: 127.0.0.1, server: 0.0.0.0:443
2016/10/12 17:39:55 [error] 3023#0: *459 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: local.beerhawk.co.uk, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "local.mydomain.co.uk"

我的 ngninx conf 文件现在如下所示:

#user  RobDee;
worker_processes  auto;

#error_log  logs/error.log;
#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;
     error_log  logs/error.log;
    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;


    server {
        listen       80;
        server_name  default;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /Users/RobDee/workspace/beerhawk/web;
            index  index.html index.htm;
        }

    # HTTPS server


   server {
    listen                     443 ;
    server_name                local.mydomain.co.uk local.beer.telegraph.co.uk;

    ssl                        on;
    ssl_protocols              TLSv1 TLSv1.1 TLSv1.2;
    ssl_certificate            /usr/local/etc/nginx/cert.pem;
    ssl_certificate_key        /usr/local/etc/nginx/cert.key;

    gzip_disable "msie6";
    gzip_types text/plain application/xml application/x-javascript text/css application/json text/javascript;

    access_log  /usr/local/var/log/nginx/access.log;
    error_log   /usr/local/var/log/nginx/error.log debug;
    log_not_found off;
    root    /Users/RobDee/workspace/beerhawk/web;

    location /.htpasswd
    {
        return 403;
    }
    location ~ \.css {
        root /Users/RobDee/workspace/beerhawk/web;
        expires max;
    }

    location ~* \.(jpg|jpeg|png|gif|ico|js|woff|woff2|ttf)$ {
        root /Users/RobDee/workspace/beerhawk/web;
        access_log off;
        expires max;
    }

    location ~* \.(js|css)$ {
        expires 1y;
        log_not_found off;
    }

    location /
    {
        try_files $uri $uri/ /app_dev.php$is_args$args;
        index index.php app_dev.php;
    }

    location ~ \.php$ {
        #root /Users/RobDee/workspace/beerhawk/web;
    fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  app_dev.php;
        fastcgi_param  SCRIPT_FILENAME  $request_filename;
        include        fastcgi_params;
        #fastcgi_read_timeout 3000;

    }
    }

    include servers/*;

    }

我不知道我做错了什么...有人能帮助我吗

答案1

你们的申请需要多长时间才能得到回复?

当客户端连接超时时,我们会看到类似以下的错误:

2016/10/12 17:39:53 [info] 3023#0: *465 client closed connection while waiting for request, client: 127.0.0.1, server: 0.0.0.0:443

例如,如果 varnish 实例在 10 秒时超时,而 nginx 愿意等待 30 秒以获得 PHP 响应,则 varnish 将在 Nginx 响应之前终止连接。

错误upstream prematurely closed connection可能是 nginx 终止与 PHP 的连接。我不太确定,因为我不记得处理过这个错误!

希望这对 OP 有帮助 :)

相关内容