December 22, 2010 08:20PM
Hi,

On 22/12/2010 21:26, Sirsiwal, Umesh wrote:
>
> All,
>
> 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.
>
> Is this the best solution for this problem? Will that affect
> subrequest response concatenation?
>
I think you can do this now using the echo module
(http://wiki.nginx.org/HttpEchoModule), subrequests and try_files

e.g.

location /main {
echo_location /sub1; # could also be echo_location_async
echo_location /sub2; # (ditto)
}

location /sub1 {
try_files ...
}

location /sub 2 {
try_files ...
}

Where ... in try_files are the separate proxy locations.

I'm not certain (and I've not tested / looked at the code) what happens
when a proxied request returns a non-200 response, but I am assuming
that try_files tries the next location on the list. If it does (and it
should if it doesn't), and you know the URL of the new testing location,
then this method should work.

A word of caution about using both synchronous and asynchronous echo_
commands next to one another. There used to be (and I'm not sure if
they've been fixed yet or not) issues with this. Use either sync or
async combined and you should be fine (async is probably a better
option, since it's likely to give a faster response to the client in
this case).

Cheers,

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

Proxy Retry Logic

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

Re: Proxy Retry Logic

Maxim Dounin 910 December 22, 2010 06:40PM

RE: Proxy Retry Logic

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

Re: Proxy Retry Logic

Eugaia 923 December 22, 2010 08:20PM

RE: Proxy Retry Logic

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

Re: Proxy Retry Logic

Eugaia 1014 December 22, 2010 09:10PM

RE: Proxy Retry Logic

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

Re: Proxy Retry Logic

Eugaia 895 December 22, 2010 09:38PM

RE: Proxy Retry Logic

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

Re: Proxy Retry Logic

Eugaia 1141 December 23, 2010 04:00AM

Re: Proxy Retry Logic

Eugaia 971 December 23, 2010 04:36AM

RE: Proxy Retry Logic

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

Re: Proxy Retry Logic

Eugaia 848 December 22, 2010 09:22PM



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

Online Users

Guests: 116
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready