本文共 3685 字,大约阅读时间需要 12 分钟。
Nginx与Tomcat的配置主要用于前端反向代理和负载均衡,以下是常见的配置示例:
http { server { location /xht { root html; index index.html index.htm; proxy_pass http://192.168.1.111:8080/xht; } }} # 限流20MB,允许1000次/秒limit_req_zone $binary_remote_addr zone=perip:20m rate=1000r/s;# 总限流20MB,允许1000次/秒limit_req_zone $binary_remote_addr zone=totalLimit:20m rate=1000r/s;# 附件上传设置location /uploadAttach.do { limit_conn uploadLimit 1; limit_rate 512k;} 不同大小的上传设置,适用于不同的场景:
limit_conn_zone $binary_remote_addr zone=uploadLimit:5m;location /xht { root html; index index.html index.htm; proxy_pass http://192.168.1.111:8080/xht;}location /uploadAttach.do { limit_conn uploadLimit 1; limit_rate 512k;} limit_conn_zone $binary_remote_addr zone=uploadLimit:10m;location /xht { root html; index index.html index.htm; proxy_pass http://192.168.1.111:8080/xht;}location /uploadAttach.do { limit_conn uploadLimit 1; limit_rate 512k;} limit_conn_zone $binary_remote_addr zone=uploadLimit:15m;location /xht { root html; index index.html index.htm; proxy_pass http://192.168.1.111:8080/xht;}location /uploadAttach.do { limit_conn uploadLimit 1; limit_rate 512k;} limit_conn_zone $binary_remote_addr zone=uploadLimit:18m;location /xht { root html; index index.html index.htm; proxy_pass http://192.168.1.111:8080/xht;}location /uploadAttach.do { limit_conn uploadLimit 1; limit_rate 512k;} limit_req_zone $binary_remote_addr zone=feqLimit:20m rate=50r/s;location /xht { root html; index index.html index.htm; proxy_pass http://192.168.1.111:8080/xht;}location /login_gis/loginVerify.do { limit_req zone=feqLimit burst=50;}location /userLogin.do { limit_req zone=feqLimit burst=50;}location /sendXhyPos.do { limit_req zone=feqLimit burst=50;}location /getMessage.do { limit_req zone=feqLimit burst=50;} limit_req_zone $binary_remote_addr zone=feqLimit:20m rate=100r/s;location /xht { root html; index index.html index.htm; proxy_pass http://192.168.1.111:8080/xht;}location /login_gis/loginVerify.do { limit_req zone=feqLimit burst=100;}location /userLogin.do { limit_req zone=feqLimit burst=100;}location /sendXhyPos.do { limit_req zone=feqLimit burst=100;}location /getMessage.do { limit_req zone=feqLimit burst=100;} limit_req_zone $binary_remote_addr zone=feqLimit:20m rate=150r/s;location /xht { root html; index index.html index.htm; proxy_pass http://192.168.1.111:8080/xht;}location /login_gis/loginVerify.do { limit_req zone=feqLimit burst=150;}location /userLogin.do { limit_req zone=feqLimit burst=150;}location /sendXhyPos.do { limit_req zone=feqLimit burst=150;}location /getMessage.do { limit_req zone=feqLimit burst=150;} limit_req_zone $binary_remote_addr zone=feqLimit:20m rate=200r/s;location /xht { root html; index index.html index.htm; proxy_pass http://192.168.1.111:8080/xht;}location /login_gis/loginVerify.do { limit_req zone=feqLimit burst=200;}location /userLogin.do { limit_req zone=feqLimit burst=200;}location /sendXhyPos.do { limit_req zone=feqLimit burst=200;}location /getMessage.do { limit_req zone=feqLimit burst=200;} limit_conn uploadLimit 1;limit_req_zone $binary_remote_addr zone=feqLimit:20m rate=100r/s;转载地址:http://vexj.baihongyu.com/