-
-
Save thresheek/2fa6479ffb7aca710493 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream backends { | |
server 127.0.0.1:8081; | |
server 127.0.0.1:8082; | |
} | |
map $request_method $nonidempotent { | |
'POST' 1; | |
'PUT' 1; | |
'DELETE' 1; | |
default 0; | |
} | |
server { | |
listen 80; | |
location / { | |
if ($nonidempotent) { | |
rewrite ^ @nonidem last; | |
} | |
proxy_pass http://backends; | |
} | |
location = @nonidem { | |
internal; | |
proxy_next_upstream off; | |
proxy_pass http://backends$request_uri; | |
} | |
} |
Ah, I see. The rewrite defines it.
What if one of the upstream servers is down? Since proxy_next_upstream is off, does that mean 50% of PUT/POST/DELETE calls will fail? Is there a way to still allow proxy_next_upstream during upstream connection failure (eg: connection timeout or connection refused)? Since it is not even connected and request is not sent to failed upstream, it should be safe to try next upstream.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hm, where is
@nonidem
defined?