Klaus Demo nginx / ca1a505
Upstream: allow recovery from "429 Too Many Requests" response. This change adds "http_429" parameter to "proxy_next_upstream" for retrying rate-limited requests, and to "proxy_cache_use_stale" for serving stale cached responses after being rate-limited. Signed-off-by: Piotr Sikora <piotrsikora@google.com> Piotr Sikora 3 years ago
6 changed file(s) with 16 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
210210 { ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 },
211211 { ngx_string("http_403"), NGX_HTTP_UPSTREAM_FT_HTTP_403 },
212212 { ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 },
213 { ngx_string("http_429"), NGX_HTTP_UPSTREAM_FT_HTTP_429 },
213214 { ngx_string("updating"), NGX_HTTP_UPSTREAM_FT_UPDATING },
214215 { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF },
215216 { ngx_null_string, 0 }
219219 { ngx_string("http_504"), NGX_HTTP_UPSTREAM_FT_HTTP_504 },
220220 { ngx_string("http_403"), NGX_HTTP_UPSTREAM_FT_HTTP_403 },
221221 { ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 },
222 { ngx_string("http_429"), NGX_HTTP_UPSTREAM_FT_HTTP_429 },
222223 { ngx_string("updating"), NGX_HTTP_UPSTREAM_FT_UPDATING },
223224 { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF },
224225 { ngx_null_string, 0 }
8181 { ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 },
8282 { ngx_string("http_403"), NGX_HTTP_UPSTREAM_FT_HTTP_403 },
8383 { ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 },
84 { ngx_string("http_429"), NGX_HTTP_UPSTREAM_FT_HTTP_429 },
8485 { ngx_string("updating"), NGX_HTTP_UPSTREAM_FT_UPDATING },
8586 { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF },
8687 { ngx_null_string, 0 }
113113 { ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 },
114114 { ngx_string("http_403"), NGX_HTTP_UPSTREAM_FT_HTTP_403 },
115115 { ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 },
116 { ngx_string("http_429"), NGX_HTTP_UPSTREAM_FT_HTTP_429 },
116117 { ngx_string("updating"), NGX_HTTP_UPSTREAM_FT_UPDATING },
117118 { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF },
118119 { ngx_null_string, 0 }
435435 { 504, NGX_HTTP_UPSTREAM_FT_HTTP_504 },
436436 { 403, NGX_HTTP_UPSTREAM_FT_HTTP_403 },
437437 { 404, NGX_HTTP_UPSTREAM_FT_HTTP_404 },
438 { 429, NGX_HTTP_UPSTREAM_FT_HTTP_429 },
438439 { 0, 0 }
439440 };
440441
41234124
41244125 case NGX_HTTP_UPSTREAM_FT_HTTP_404:
41254126 status = NGX_HTTP_NOT_FOUND;
4127 break;
4128
4129 case NGX_HTTP_UPSTREAM_FT_HTTP_429:
4130 status = NGX_HTTP_TOO_MANY_REQUESTS;
41264131 break;
41274132
41284133 /*
2525 #define NGX_HTTP_UPSTREAM_FT_HTTP_504 0x00000080
2626 #define NGX_HTTP_UPSTREAM_FT_HTTP_403 0x00000100
2727 #define NGX_HTTP_UPSTREAM_FT_HTTP_404 0x00000200
28 #define NGX_HTTP_UPSTREAM_FT_UPDATING 0x00000400
29 #define NGX_HTTP_UPSTREAM_FT_BUSY_LOCK 0x00000800
30 #define NGX_HTTP_UPSTREAM_FT_MAX_WAITING 0x00001000
31 #define NGX_HTTP_UPSTREAM_FT_NON_IDEMPOTENT 0x00002000
28 #define NGX_HTTP_UPSTREAM_FT_HTTP_429 0x00000400
29 #define NGX_HTTP_UPSTREAM_FT_UPDATING 0x00000800
30 #define NGX_HTTP_UPSTREAM_FT_BUSY_LOCK 0x00001000
31 #define NGX_HTTP_UPSTREAM_FT_MAX_WAITING 0x00002000
32 #define NGX_HTTP_UPSTREAM_FT_NON_IDEMPOTENT 0x00004000
3233 #define NGX_HTTP_UPSTREAM_FT_NOLIVE 0x40000000
3334 #define NGX_HTTP_UPSTREAM_FT_OFF 0x80000000
3435
3738 |NGX_HTTP_UPSTREAM_FT_HTTP_503 \
3839 |NGX_HTTP_UPSTREAM_FT_HTTP_504 \
3940 |NGX_HTTP_UPSTREAM_FT_HTTP_403 \
40 |NGX_HTTP_UPSTREAM_FT_HTTP_404)
41 |NGX_HTTP_UPSTREAM_FT_HTTP_404 \
42 |NGX_HTTP_UPSTREAM_FT_HTTP_429)
4143
4244 #define NGX_HTTP_UPSTREAM_INVALID_HEADER 40
4345