4

Nginx proxy_next_upstream non_idempotent

 1 year ago
source link: https://fann.im/blog/2019/01/28/nginx-proxy_next_upstream/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Nginx proxy_next_upstream non_idempotent

Jan 28, 2019

在 Nginx 做反向代理的时候,我们一般会配置 proxy_next_upstream,如果某个 upstream 超时或出错,自动切换到下一个 upstram。

upstream backend{
  server 192.168.0.1;
  server 192.168.0.2;
}
location /example/ {
   proxy_pass http://backend;

   proxy_next_upstream error timeout http_500 non_idempotent;
}

这里有一个地方需要注意,non_idempotent,Nginx 默认对 non-idempotent 请求,比如 POST/LOCK/PATCH,是不进行重试。常见的情况就是 POST 请求出错后不会重试,需要加上该设置。

normally, requests with a non-idempotent method (POST, LOCK, PATCH) are not passed to the next server if a request has been sent to an upstream server (1.9.13); enabling this option explicitly allows retrying such requests;

Was this page helpful?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK