【问题标题】:Nginx: Couldn't forward the HTTP response back to the HTTP clientNginx:无法将 HTTP 响应转发回 HTTP 客户端
【发布时间】:2012-10-22 18:48:01
【问题描述】:

我有一个带有下一个组件的服务器:

  • Ubuntu 12.04
  • Nginx 1.2.2
  • 乘客 3.0.15

我正在此服务器上运行 Ruby on Rails 应用程序。 现在在我的 Nginx 的 error.log 中,我发现这个错误经常弹出。

[ pid=12615 thr=3065355072 file=ext/nginx/HelperAgent.cpp:923 time=2012-10-22 09:31:03.929 ]: Couldn't forward the HTTP response back to the HTTP client: It seems the user clicked on the 'Stop' button in his browser.

有人知道这个问题是从哪里来的吗? 这是我的 Nginx 配置文件:

user deployer staff;
worker_processes  5;

error_log  /var/log/nginx/error.log notice;
pid        /var/log/nginx/nginx.pid;

events {
    worker_connections  2048;
    multi_accept on;
}

http {
    passenger_root /var/lib/gems/1.9.1/gems/passenger-3.0.15;
    passenger_ruby /usr/bin/ruby1.9.1;

    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  /var/log/nginx/access.log  main;

    sendfile        on;

    keepalive_timeout  65;

    server {
        passenger_enabled on;
        server_name xxx.com;
        listen       80;
        rails_env production;

        location ^~ /assets/ {
            gzip_static on;
             expires max;
             add_header Cache-Control public;
        }

        root /var/rails/alfa_paints/current/public;
        error_page  404              /404.html;

        error_page   500 502 503 504  /500.html;
    }
}

【问题讨论】:

    标签: ruby-on-rails ubuntu nginx passenger


    【解决方案1】:

    您的配置看起来不错。我认为错误正是它所说的:最终用户在他们的浏览器上单击“停止”,关闭与服务器的 TCP 连接。您的应用程序堆栈中的所有内容都可能按设计工作。除非您有最终用户抱怨应用程序无法运行,否则这是最可能的解释。

    也就是说,如果您经常看到此错误,您可能会问的下一个问题是“为什么用户如此频繁地点击停止按钮”?也许您的应用程序的一部分响应用户的时间太长,您需要加快速度或添加某种进度指示器。您可以回顾一下您的日志,看看是否可以将错误与特定类型的请求关联起来。

    【讨论】:

    • FWIW,我在类似的设置中看到了这种行为。不同的是我是提出请求的人,而且我绝对没有按下停止按钮。
    【解决方案2】:

    另一种情况可能是这样的nginx Timeout serving large requests

    要解决这个问题,你可以试试这个:

     gem install passenger #use the lastest passenger
     passenger-config --root # get passenger_root_path
     #download the lastest nginx file and cd nginx-X.X.X
     ./configure --with-http_ssl_module --with-http_gzip_static_module --with-cc-opt=-Wno-error --add-module=$passenger_root_path/ext/nginx
     make
     make install
    

    之后,配置nginx.conf并重启,你会发现一切正常!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-05
      • 2019-05-31
      • 1970-01-01
      • 2019-08-01
      • 2016-04-10
      • 1970-01-01
      • 2014-11-13
      • 2020-09-04
      相关资源
      最近更新 更多