3

All of the examples I've seen of using upstream (for load balancing) in nginx look like this:

upstream  backend  {
  server   backend1.example.com:8080          max_fails=3  fail_timeout=30s;
  server   backend2.example.com:8080          max_fails=3  fail_timeout=30s;
  server   backend3.example.com:8080          max_fails=3  fail_timeout=30s;
}

It seems repetitive to re-set max_fails and fail_timeout for each backend, when typically they are always the same. Is it possible to set max_fails and fail_timeout for all of the backend servers at once?

4

Specify proxy_upstream_fail_timeout and proxy_upstream_max_fails in your server {} config

See
http://wiki.nginx.org/HttpProxyModule#proxy_upstream_fail_timeout
http://wiki.nginx.org/HttpProxyModule#proxy_upstream_max_fails
For more info

| improve this answer | |
  • Thanks. Those are marked as deprecated, is there any reason why that is? – John Smith May 22 '11 at 17:25
  • 1
    Hmm not sure, didn't realize they were depreciated (Posted the links from memory) but I'm running NGINX 1.0.1 and those directives still work, there may be a performance benefit from using the directives in an upstream server specifier (proxy_upstream_* relates to using the proxy mod, upstream {} flags apply to the upstream module. I'll do a bit of research (If there is a difference it would be beneficial to my own applications) and get back to you – Smudge May 22 '11 at 17:34
  • Will proxy_upstream_* make Nginx send the request to one of the other upstream servers on error? Intuitively I don't think so. – i.amniels May 23 '11 at 18:22
  • They're marked as deprecated because you should set them on the server directive now – Dan Esparza Aug 28 '15 at 17:52
  • Unfortunately, it seems that these options have been removed by now. – phihag Jul 19 '19 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.