Q & A
鏈接超時
ServletOutputStream failed to flush: java.io.IOException: 連線已被您主機上的軟體中止。
Ngnix default timeout 60s, 如果請求超過60s Nginx將主動切斷。所以需要更改default的 timeout
location /rest{
proxy_http_version 1.1;
proxy_pass http://aaaaa/bbbbbb/;
proxy_connect_timeout 120s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
send_timeout 600s;
}
基础环境
环境变量
Path = C:\myapp\jdk1.8.0_201\bin
JAVA_HOME = C:\myapp\jdk1.8.0_201
CATALINA_HOME = C:\myapp\apache-tomcat-10.0.12
tomcat

Nginx
Nginx(“engine x”)是一款高性能的 Web和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。在高连接并发的情况下,Nginx是Apache服务器不错的替代品。Download,[源码(https://trac.nginx.org/nginx/browser)
和官网。
1.Http代理,反向代理,Nginx在做反向代理时,提供性能稳定,并且能够提供配置灵活的转发功能。Nginx可以根据不同的正则匹配,采取不同的转发策略,比如图片文件结尾的走文件服务器,动态页面走web服务器,只要你正则写的没问题,又有相对应的服务器解决方案,你就可以随心所欲的玩。并且Nginx对返回结果进行错误页跳转,异常判断等。如果被分发的服务器存在异常,他可以将请求重新转发给另外一台服务器,然后自动去除异常服务器。
2.负载均衡,Nginx提供的负载均衡策略有2种:内置策略和扩展策略。内置策略为轮询,加权轮询,Ip hash。扩展策略,根据负载均衡算法实现。
Ip hash算法,对客户端请求的ip进行hash操作,然后根据hash结果将同一个客户端ip的请求分发给同一台服务器进行处理,可以解决session不共享的问题。
3.web缓存,Nginx可以对不同的文件做不同的缓存处理,配置灵活,并且支持FastCGI_Cache,主要用于对FastCGI的动态程序进行缓存。配合着第三方的ngx_cache_purge,对制定的URL缓存内容可以的进行增删管理。
启动Nginx
C:\myapp\nginx-1.21.3>start nginx
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
windows下查看Nginx启动状态
tasklist /fi "imagename eq nginx.exe"

检查Nginx配置是否正确
C:\myapp\nginx-1.21.3>nginx -t -c conf/nginx.conf
nginx: the configuration file C:\nginx-1.21.3/conf/nginx.conf syntax is ok
nginx: configuration file C:\nginx-1.21.3/conf/nginx.conf test is successful
重启Nginx
C:\myapp\nginx-1.21.3>nginx -s reload
关闭Nginx
快速停止 nginx -s stop
或者
完整有序的关闭 nginx -s quit
Nginx与Tomcat运维指南



955

被折叠的 条评论
为什么被折叠?



