Welcome! Log In Create A New Profile

Advanced

RE: Proxy Retry Logic

Sirsiwal, Umesh
December 22, 2010 07:56PM
Thanks Maxim,
I assumed that post_subrequest handler will be called once all the handling about the current subrequest (including error_page handling) is complete. That assumption is obviously incorrect.

Also, because the new proxy request will still be sent from the context of original subrequest, presumably I will get another post_subrequest callback once the new fallback proxy has completed?

-Umesh
________________________________________
From: Maxim Dounin [mdounin@mdounin.ru]
Sent: Wednesday, December 22, 2010 6:38 PM
To: nginx-devel@nginx.org
Subject: Re: Proxy Retry Logic

Hello!

On Wed, Dec 22, 2010 at 02:26:56PM -0500, Sirsiwal, Umesh wrote:

> I am trying to write a module which uses a number of subrequests
> to talk to backend servers. Combines the responses and sends
> them back to the client. The communication with the backend
> server is using HTTP and I am using proxy_pass for that.
>
> The peculiarity in our setup is that on failure-retry I need to
> use a different URI than the original request. Current, proxy
> reinit request does not regenerate request hence cannot be used
> for the purpose. I tried using the error_page in the subrequest
> location to point to a different location. But, it seems that
> the error_page is not evaluated on subrequest. The only option I
> can think of is for my module to detect error and issue a new
> subrequest.

Fallback via error_page should work ok for subrequests. It may be
disabled from post_subrequest handler though: if you use it and
return something like NGX_OK from there (i.e. not NGX_HTTP_...
error), error_page handling won't be executed assuming you've
handled problem yourself.

Take a look at ngx_http_finalize_request(), it's more or less
clear how it works. Relevant parts are:

if (r != r->main && r->post_subrequest) {
rc = r->post_subrequest->handler(r, r->post_subrequest->data, rc);
}
...
if (rc >= NGX_HTTP_SPECIAL_RESPONSE
|| rc == NGX_HTTP_CREATED
|| rc == NGX_HTTP_NO_CONTENT)
{
...
ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc));
return;
}

(ngx_http_special_response_handler() is where actual error_page handling
happens).

Maxim Dounin

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Proxy Retry Logic

Sirsiwal, Umesh 2508 December 22, 2010 02:28PM

Re: Proxy Retry Logic

Maxim Dounin 959 December 22, 2010 06:40PM

RE: Proxy Retry Logic

Sirsiwal, Umesh 1046 December 22, 2010 07:56PM

Re: Proxy Retry Logic

Eugaia 971 December 22, 2010 08:20PM

RE: Proxy Retry Logic

Sirsiwal, Umesh 1017 December 22, 2010 08:52PM

Re: Proxy Retry Logic

Eugaia 1072 December 22, 2010 09:10PM

RE: Proxy Retry Logic

Sirsiwal, Umesh 884 December 22, 2010 09:26PM

Re: Proxy Retry Logic

Eugaia 951 December 22, 2010 09:38PM

RE: Proxy Retry Logic

Sirsiwal, Umesh 962 December 22, 2010 09:52PM

Re: Proxy Retry Logic

Eugaia 1189 December 23, 2010 04:00AM

Re: Proxy Retry Logic

Eugaia 1026 December 23, 2010 04:36AM

RE: Proxy Retry Logic

Sirsiwal, Umesh 1211 December 23, 2010 08:12AM

Re: Proxy Retry Logic

Eugaia 910 December 22, 2010 09:22PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 317
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready