nginx 反向代理重试机制
upstream tomcatserver1 { server 192.168.1.9:8081 weight=2; server 192.168.1.29:8081 weight=2; } server { listen 8082; listen 192.168.1.29:8082; server_name 192.168.1.29; location / { proxy_pass http://tomcatserver1; index index.html index.htm; proxy_next_upstream error timeout http_503 non_idempotent; //当后端服务器超时或者返回http响应码为503时,重试当前请求,把请求发向下一个后端服务器来重试,non_idempotent 参数会强制重试,即使HTTP method是Post、Patch等非幂等方法 proxy_connect_timeout 20s; proxy_read_timeout 20s; proxy_send_timeout 20s; #开启gzip压缩,降低传输流量 gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml application/json image/jpeg image/gif image/png; gzip_vary on; } }