Nginx重试机制

来自ling
跳转至: 导航搜索

<source lang=vim>

upstream backend {

   server backend1;
   server backend2;

}

server {

   server_name proxy;
   location / {
       error_page 598 = @retry;
       error_page 599 = @no_retry;
       if ($request_method = POST) {
           return 599;
       }
       return 598;
   }
   location @retry {
       proxy_pass http://backend;
   }
   location @no_retry {
       proxy_pass http://backend;
       proxy_next_upstream off;
   }

}