server 2012服务器,刚学着搭建的nginx,就做了个均衡,把所有请求发到两个tomcat上,
upstream local {
server localhost:8080;
server localhost:8081;
}
server {
listen 80;
server_name localhost;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css|html)$ {
expires 30d;
}
location ~ ^/(WEB-INF)/ {
deny all;
}
location / {
proxy_pass http://local;
}
}
然后打开localhost,间歇性的非常卡,10秒都加载不出来页面。
错误日志里有这些记录,请问这问题该怎么解决?
2014/12/31 06:10:45 [error] 3204#688: *4 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: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "http://[::1]:8081/", host: "localhost"
2014/12/31 06:10:45 [error] 3204#688: *4 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: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "http://[::1]:8081/", host: "localhost"
经过测试,upstream xxx 中加入ip_hash就不卡了,原因不知道,原谅我是菜鸟
upstream test {
ip_hash;
server localhost:8081;
server localhost:8080;
}