nginx不向上游转发

时间:2012-06-12 15:18:02

标签: nginx python-2.7 paster

我有一个贴纸服务器,设置为使用nginx代理托管多个应用程序。由于某种原因,似乎请求不是从nginx上游发送的。我在客户端收到404错误,我在日志中找到的唯一“错误”是来自nginx_error.log的以下行(大约每5秒生成一次):

  

2012/06/12 10:29:37 [info] 22289#0:* 49客户过早关闭   读取客户端请求行时连接,客户端:192.168.10.135,   server:localhost

谷歌的一些高质量时间表明这不是一个破坏应用程序的问题,但我现在必须继续这样做。

nginx.access.log每5秒打印一次以下行:

  

- [12 / Jun / 2012:10:3​​1:13 -0400] -4000 -

尽管应用程序中有多条日志消息,但没有任何用户操作的条目正在打印到应用程序日志中。

作为参考,我的nginx.cfg看起来像是:

daemon             off; 
error_log          /APP_DIRECTORY/logs/nginx_error.log info; 
pid                /APP_DIRECTORy/var/nginx.pid; 
worker_processes   1;  
working_directory  /APP_DIRECTORY/var/;  

events {
  worker_connections 1024; 
}


http {   
  # the three parameters for *_temp_path MUST be here or nginx will not start   
  client_body_temp_path /APP_DIRECTORY/var/lib/nginx/body;   
  proxy_temp_path       /APP_DIRECTORY/var/lib/nginx/proxy;   
  fastcgi_temp_path     /APP_DIRECTORY/var/lib/nginx/fastcgi;   
  include               /etc/nginx/mime.types;   
  default_type          application/octet-stream;  

  log_format            main $http_x_forwarded_for - [$time_local] "$request" $status $body_bytes_sent  "$http_referer" "$http_user_agent";  
  sendfile              on;   
  keepalive_timeout     0;   
  tcp_nodelay           on;  

  gzip                  on;   
  Gzip_proxied          any;   
  gzip_types            text/plain text/html application/json application/xml;

  upstream app_paste {
    server 127.0.0.1:8001;
    #server 127.0.0.1:8002;
    #server 127.0.0.1:8003;
    #server 127.0.0.1:8004;
    #server 127.0.0.1:8005;
    #server 127.0.0.1:8006;
    #server 127.0.0.1:8007;
    #server 127.0.0.1:8008;
    #server 127.0.0.1:8009;
    #server 127.0.0.1:8010;
    #server 127.0.0.1:8011;
    #server 127.0.0.1:8012;   
  }

  server {
    listen 8000;
    server_name localhost;
    access_log /app_DIRECTORY/logs/nginx.access.log main;

    location /crossdomain.xml {
      root /APP_DIRECTORY/www;
    }

    location /v1 {
      proxy_pass http://app_paste;
    }

    location /v2 {
      proxy_pass http://app_paste;
    }   
  } 
}

我的应用程序配置如下:

[DEFAULT]  
loglevel = INFO  
beaker.session.cookie_expires = true  
beaker.session.lock_dir = .
beaker.session.type = mongodb  
beaker.session.url = mongodb://MONGO_HOST:MONGO_PORT/beaker.sessions?slaveok=true  
beaker.session.skip_pickle = true  

[composite:main]  
use = egg:Paste#urlmap  
/v1/cust1 = cust1  

[app:cust1]  
paste.app_factory = appservice.main:make_app  
company = customer1  
db_host = DB_HOST  
db_port = DB_PORT  
db_name = DB_NAME  
DATA_COLLECTION = customer_data  
USERS_COLLECTION = customer_users  
REPORT_PARAM_1 = REPORT_PARAM_1_DATA  
REPORT_PARAM_2 = REPORT_PARAM_2_DATA  
REPORT_PARAM_3 = REPORT_PARAM_3_DATA  
REPORT_PARAM_4 = REPORT_PARAM_4_DATA  
REPORT_PARAM_5 = REPORT_PARAM_5_DATA  
REPORT_PARAM_6 = REPORT_PARAM_6_DATA  

[server:main]  
use = egg:Paste#http    
host = 0.0.0.0  
port = %(app_port)s

可能导致此问题的原因是什么?我的配置有问题吗?

1 个答案:

答案 0 :(得分:0)

我改变了处理配置文件的方式,以使用传递给我的app工厂的参数,而不是手动解析应用程序中的文件。出于某种原因,我根本不明白,这似乎解决了这个问题。 @mikhailov,感谢您的所有时间和帮助。