2

Does nginx go to the next host in upstream block, if previous host not available or doesn't exist?

upstream cache_cluster {
   127.0.0.1:9000;     //something on this port
   127.0.0.1:11211;   //memcached instance on this port
}

location  {
 //..some code here
 memcached_pass cache_cluster;
 error_page 404 502 504 =  @something;
}
shatzibtten
  • 45
  • 1
  • 4

1 Answers1

2

upstream only provide a list of servers, and some kind of weight. To tell Nginx what to do if one of the servers fail, you need to control this with memcached_next_upstream.

From the Nginx-documentation:

memcached_next_upstream

syntax: memcached_next_upstream [ error | timeout | invalid_response | not_found | off ]

default: error timeout

context: http, server, location

Which failure conditions should cause the request to be forwarded to another upstream server? Applies only when the value in memcached_pass is an upstream with two or more servers.

As stated in the documentation, the default behaviour is error / timeout, which should be sufficient in most cases.

Kvisle
  • 4,193
  • 24
  • 25