I want nginx to prevent trying the next upstream if the request is a
POST
request and the request just timed out. POSTs should only be repeated on
error. I tried this config to implement it:
if ($request_method = POST) {
proxy_next_upstream error;
}
But this fails with:
nginx: [emerg] “proxy_next_upstream” directive is not allowed here…
I tried it within location context as well as server context, but got
always
the same error while configurations like these are running fine:
if ($request_method = POST) {
return 403;
}
Or just (without if):
proxy_next_upstream error;
Is this a bug in nginx or is this related to “if is evil”?
(If is Evil… when used in location context | NGINX)
What is the best way to implement the above functionality with ningx?
Posted at Nginx Forum: