nginx加载页面非常慢

我刚刚在一个新的环境中部署了nginx,使用了之前使用过的相同的configuration,我看到一些非常奇怪的行为。

Nginxconfiguration为Solr的反向代理,当我尝试通过nginx访问Solr UI时,加载需要大约一分钟的时间。 我检查了Chrome开发工具,看起来浏览器能够立即下载6个文件,但是其他所有请求都处于未决状态。 然后,它只是坐在那里一分钟,之后,所有下载和页面加载。 之后,浏览速度很快; 我认为这主要是因为本地浏览器caching。

这是configuration:

worker_processes 10; error_log /directory/path/error.log debug; pid /directory/path/nginx1.pid; events { worker_connections 1024; } http { access_log /directory/path/access.log; proxy_temp_path /directory/path/ 1 2; upstream backend-test-old { server 1.1.1.1:7071; server 2.2.2.2:7071; } server { listen 7071; server_name localhost; access_log /directory/path/access_7071.log; proxy_ignore_headers "Set-Cookie"; proxy_hide_header "Set-Cookie"; location /solr { proxy_pass http://backend-test-old; } } } 

我也在日志中看到很多这些:

 2015/07/10 11:06:38 [warn] 31503#0: *120 an upstream response is buffered to a temporary file /dir/path/7/00/0000000007 while reading upstream, client: 111.111.111.111 2015/07/10 11:06:36 [info] 31503#0: *96 client prematurely closed connection, so upstream connection is closed too while connecting to upstream, 2015/07/10 11:06:36 [error] 31503#0: *101 upstream timed out (110: Connection timed out) while connecting to upstream, client: 

现在这是不是我的开发服务器上的问题,它运行相同的configuration,应该configuration相对相似,所以它可能是系统相关的东西,但我不知道。

任何帮助将非常感激。

谢谢

编辑:

看起来问题是我指向后端主机的IP与主机名。 我不知道为什么这是一个问题。 我已经实现了这个configuration:

 worker_processes 10; error_log /path/error.log debug; pid /path/nginx1.pid; events { worker_connections 1024; } http { access_log /path/access.log; proxy_temp_path /pathproxy_temp/ 1 2; upstream backend-test-old { server hostname-for-1.1.1.1:7071; server hostname-for-2.2.2.2:7071; } upstream backend-test-old2 { server 1.1.1.1:7071; server 2.2.2.2:7071; } server { listen 7071; server_name localhost; access_log /path/access_7071.log; proxy_ignore_headers "Set-Cookie"; proxy_hide_header "Set-Cookie"; location /solr { proxy_pass http://backend-test-old; } } server { listen 7072; server_name localhost; access_log /path/access_7072.log; proxy_ignore_headers "Set-Cookie"; proxy_hide_header "Set-Cookie"; location /solr { proxy_pass http://backend-test-old2; } } } 

如果我经过7071就可以正常工作,但是如果我打到7072,就会出现上述的性能问题。 有没有人有任何想法?

缓冲导致问题,完全closures它:

 proxy_buffering off; 

有关详细信息,请参阅官方文档 :

当缓冲被禁用时,响应将在收到时立即同步传递给客户端。 nginx不会尝试从代理服务器读取整个响应。 nginx一次可以从服务器接收的最大数据量由proxy_buffer_size指令设置。