<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
Hi,<br>
<br>
On 22/12/2010 21:26, Sirsiwal, Umesh wrote:
<blockquote
cite="mid:B293D35E9E20694A8D9DFFE1BC655C556757F14FFE@vvexch.verivue.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<meta name="Generator" content="Microsoft Word 12 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">All,<o:p></o:p></p>
<p class="MsoNormal">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. <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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. <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Is this the best solution for this problem?
Will that affect subrequest response concatenation? </p>
</div>
</blockquote>
I think you can do this now using the echo module (<a
href="http://wiki.nginx.org/HttpEchoModule">http://wiki.nginx.org/HttpEchoModule</a>),
subrequests and try_files<br>
<br>
e.g.<br>
<br>
location /main {<br>
echo_location /sub1; # could also be echo_location_async<br>
echo_location /sub2; # (ditto)<br>
}<br>
<br>
location /sub1 {<br>
try_files ...<br>
}<br>
<br>
location /sub 2 {<br>
try_files ...<br>
}<br>
<br>
Where ... in try_files are the separate proxy locations.<br>
<br>
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.<br>
<br>
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).<br>
<br>
Cheers,<br>
<br>
Marcus.<br>
</body>
</html>