Welcome! Log In Create A New Profile

Advanced

Nginx and conditional proxy_next_upstream directive

February 11, 2016 10:14AM
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"? (https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/)

What is the best way to implement the above functionality with ningx?
Subject Author Posted

Nginx and conditional proxy_next_upstream directive

dontknowwhoiam February 11, 2016 10:14AM

Re: Nginx and conditional proxy_next_upstream directive

dontknowwhoiam February 23, 2016 10:09AM

Re: Nginx and conditional proxy_next_upstream directive

Tolga Ceylan February 23, 2016 08:42PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 63
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready