Nginx在没有任何日志记录的情况下在proxy_pass上超时

时间:2015-02-24 22:03:33

标签: nginx proxy

我使用NGINX进行反向代理/负载均衡到我的Ruby On Rails应用程序,在使用fastcgi的其他php应用程序的服务器上,但它们没有任何问题。 我有NGINX的问题只是停止提供连接,它不会出现在任何访问日志或错误日志中。

当我点击我的应用程序并得到一个超时错误时,我注意到了这个问题,在nginx或unicorn中根本没有出现在日志中。

我测试了从套接字到端口的更改以及对该端口的基准测试,但是如果我将其更改为nginx,它将失败大部分甚至全部。

我的nginx配置如下所示:

upstream unicorn_app_production {
    #server unix:/tmp/unicorn.app_production.sock;
    server localhost:8080;
}



server {

  listen 80;


  client_max_body_size 4G;
  keepalive_timeout 600s;

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

  server_name dev.app.com;
  server_name_in_redirect off;
  port_in_redirect        off;

  root /var/www/rails.app.com/current/public;
  #try_files $uri/index.html $uri @unicorn_app_production;

  location / {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;

    proxy_pass http://unicorn_app_production;
    #proxy_read_timeout 180s;
    proxy_connect_timeout       300;
    proxy_send_timeout          300;
    proxy_read_timeout          300;
    send_timeout                300;
    proxy_next_upstream error;
    # limit_req zone=one;
    access_log /var/log/nginx/app_production.access.log;
    error_log /var/log/nginx/app_production.error.log;
  }
...
}

如果nginx可以处理我的连接,我使用siege进行测试: siege -c 5 -r 5 http://dev.app.com:8080直接针对独角兽而没有8080就是nginx。直接到unicorn工作没有任何问题,但对nginx它将看起来像这样:

/# siege -c 5 -r 5 http://dev.app.com
** SIEGE 2.70
** Preparing 5 concurrent users for battle.
The server is now under siege...socket: connection timed out
socket: connection timed out
socket: connection timed out
socket: connection timed out
socket: connection timed out
^C
Lifting the server siege...      done.                                                                                                                                                         
Transactions:                  10 hits
Availability:                  66.67 %
Elapsed time:                  39.52 secs
Data transferred:               0.03 MB
Response time:                  0.10 secs
Transaction rate:               0.25 trans/sec
Throughput:                     0.00 MB/sec
Concurrency:                    0.03
Successful transactions:          10
Failed transactions:               5
Longest transaction:            0.13
Shortest transaction:           0.05

问题是什么,我做错了什么?

PS。证明我的独角兽完全正常工作:

/# siege -c 20 -r 6 http://dev.app.com:8080
** SIEGE 2.70
** Preparing 20 concurrent users for battle.
The server is now under siege..      done.                                                                                                                                                     Transactions:                     120 hits
Availability:                 100.00 %
Elapsed time:                   4.63 secs
Data transferred:               1.32 MB
Response time:                  0.12 secs
Transaction rate:              25.92 trans/sec
Throughput:                     0.29 MB/sec
Concurrency:                    2.99
Successful transactions:         120
Failed transactions:               0
Longest transaction:            0.28
Shortest transaction:           0.05

0 个答案:

没有答案