Nginx Timeout的问题,使用的Tomcat

CapJes 发布于 2015/09/16 13:13
阅读 397
收藏 0

Nginx的error日志为:


2015/09/16 13:07:22 [error] 2144#4008: *556 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 221.237.157.69, server: cms.caitb.com, request: "GET /cms/ HTTP/1.1", upstream: "http://[::1]:8081/cms/", host: "cms.caitb.com"

完全不知道怎么回事了,Nginx转发到Tomcat这个过程非常缓慢,长达1.5min以上,可以用上面的域名访问测试下。

相关配置参数:

server {
        listen       80;
        server_name  cms.caitb.com;
		
		location ~ .*\.(htm|html|gif|jpeg|png|bmp|swf|ioc|rar|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma|woff|jpg)$ {   #设置静态网页直接由nginx进行处理
			root D:/APP/apache-tomcat-8.0.26-8081/webapps;
			expires 30d;
		}
		
		location ~ .*\.(js|css)?$ {
			root D:/APP/apache-tomcat-8.0.26-8081/webapps;
			expires 1h;
		}
		
		
        location / {
            proxy_pass http://localhost:8081;
			
			proxy_redirect          off;
			proxy_set_header        Host $host;
			client_max_body_size    10m;
			client_body_buffer_size 128k;
			proxy_connect_timeout   90;
			proxy_send_timeout      150;
			proxy_read_timeout      150;
			proxy_buffer_size       16k;
			proxy_buffers           4 64k;
			proxy_busy_buffers_size 128k;
			proxy_temp_file_write_size 128k;
		  
        }
    }



加载中
1
活的自由
活的自由

proxy_pass http://localhost:8081;

localhost 换成IP试试

CapJes
CapJes
多谢哥们,真是一语道破天机啊,确实快很多啊。能解释下什么原因呢?
0
51clocker
51clocker
proxy_connect_timeout 300;
proxy_read_timeout 300;
proxy_send_timeout 300;
proxy_buffer_size 64k;
proxy_buffers   4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;

值调大点试试。

proxy_redirect          off;
proxy_set_header        Host $host;
proxy_set_header        X-Real-IP $remote_addr;
proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;



把这个也加上吧,没全部代理过去。

CapJes
CapJes
上面哪个哥们已经帮我解决了,多谢参与啦。
返回顶部
顶部