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; } }
proxy_pass http://localhost:8081;
localhost 换成IP试试
值调大点试试。