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试试
######多谢哥们,真是一语道破天机啊,确实快很多啊。能解释下什么原因呢?######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;
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。