Forum: NGINX how proxy_next_upstream control retry times

Posted by "李文伟" <wenwei.li@dianping.com> (Guest)
on 2013-02-06 04:23
(Received via mailing list)
hi
now i am looking for a 50x retry method, config like this:



   upstream jboss8080 {
    server                        10.1.2.164:8080 weight=1 max_fails=1
fail_timeout=2s;
    server                        10.1.2.174:8080 weight=1 max_fails=1
fail_timeout=2s;
    server                        10.1.2.209:8080 weight=1 max_fails=1
fail_timeout=2s;
    server                        10.1.7.136:8080 weight=1 max_fails=1
fail_timeout=2s;
    server                        10.1.7.137:8080 weight=1 max_fails=1
fail_timeout=2s;
    server                        10.1.7.138:8080 weight=1 max_fails=1
fail_timeout=2s;
  }

  server {
........
    location / {
proxy_next_upstream http_500 http_502 http_503 http_504 timeout error
invalid_header;
.......
      if ( !-f $request_filename ) {
proxy_pass                http://jboss8080;
break;
      }
    }

    error_page                    500 502 503 504  /50x.html;
      location = /50x.html {
      root                        html;
    }
  }


then how proxy_next_upstream control retry times.


by the way, i used error_page, config like this:


upstream backend  {
  server localhost:8080 weight=5;
}

upstream backup1  {
  server localhost:8081 weight=5;
}

upstream backup2  {
  server localhost:8082 weight=5;
}

    server {
listen       80;
server_name  localhost;
proxy_intercept_errors on;

location / {
    error_page  502 @backup1;
    proxy_pass  http://backend;
}

location @backup1 {
    error_page  502 @backup2;
    proxy_pass http://backup1;
}

location @backup2 {
    proxy_pass http://backup2;
}
     }

@backup1works, but @backup2 doesn't.
how can i let backup2 works.
Posted by Maxim Dounin (Guest)
on 2013-02-06 11:48
(Received via mailing list)
Hello!

On Wed, Feb 06, 2013 at 11:23:24AM +0800, 李文伟 wrote:

>     server                        10.1.2.209:8080 weight=1 max_fails=1
> ........
>     error_page                    500 502 503 504  /50x.html;
>       location = /50x.html {
>       root                        html;
>     }
>   }
>
>
> then how proxy_next_upstream control retry times.

Quote from http://nginx.org/r/upstream:

: If an error occurs when communicating with the server, a request
: will be passed to the next server, and so on until all of the
: functioning servers will be tried. If a successful response could
: not be obtained from any of the servers, the client will be
: returned the result of contacting the last server.

That is, errors are handled as they appear, and there is no
retry-specific controls except proxy_next_upstream itself.  In a
worst case all servers will be tried.

>
>     error_page  502 @backup1;
> }
>      }
>
> @backup1works, but @backup2 doesn't.
> how can i let backup2 works.

http://nginx.org/r/recursive_error_pages

--
Maxim Dounin
http://nginx.com/support.html
Posted by "李文伟" <wenwei.li@dianping.com> (Guest)
on 2013-02-07 04:08
(Received via mailing list)
thank you very much.
with *recursive_error_pages* on
it works.

2013/2/6 Maxim Dounin <mdounin@mdounin.ru>

> >     server                        10.1.2.164:8080 weight=1 max_fails=1
> > fail_timeout=2s;
> > break;
> > then how proxy_next_upstream control retry times.
> retry-specific controls except proxy_next_upstream itself.  In a
> >   server localhost:8081 weight=5;
> >
> > location @backup2 {
> Maxim Dounin
> http://nginx.com/support.html
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx




--

Regards,
ΰ
software engineer
ڵ--Ź
Tel(021)53559777-1700
Mobile:15921585268
QQ:363603327
MSN:muzi666boy@hotmail.com
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.