<div dir="ltr">In the current setup, I have<br> location / {<br>   ...<br>   bunch of stuff<br>   ...<br>   proxy_pass <a href="http://upstream.server">http://upstream.server</a>;<br>  }<br><br>Instead of duplicating the whole location block, can we do something like<br> location @http | / {<br>   ...<br>   bunch of stuff<br>   ...<br>   proxy_pass <a href="http://upstream.server">http://upstream.server</a>;<br><br> }<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 25, 2018 at 1:23 PM, Maxim Dounin <span dir="ltr"><<a href="mailto:mdounin@mdounin.ru" target="_blank">mdounin@mdounin.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello!<br>
<span class=""><br>
On Wed, Jul 25, 2018 at 11:37:20AM -0700, Frank Liu wrote:<br>
<br>
> I tried:<br>
> <br>
> error_page 497 $request_uri;<br>
> <br>
> It is kind of working, and I get the correct content/code back, but the<br>
> response header is still has 400:<br>
> <br>
> HTTP/1.1 400 Bad Request<br>
> <br>
> My use case has nginx as a reverse proxy, and the real response code from<br>
> upstream is dropped though the response body and other headers are retained.<br>
> <br>
> I also tried:<br>
> error_page 497 =200 $request_uri;<br>
> and now I get:<br>
> HTTP/1.1 200 OK<br>
> instead of real response code from upstream.<br>
<br>
</span>Try this instead:<br>
<br>
    error_page 497 = @http;<br>
<br>
    location @http {<br>
        proxy_pass <a href="http://upstream.server" rel="noreferrer" target="_blank">http://upstream.server</a>;<br>
    }<br>
<br>
But, as previously said, it might not be a good idea to actually <br>
configure things that way.  Rather, 497 can and should be used to <br>
return a proper error and/or redirection to the correct address <br>
with the protocol properly specified.<br>
<div class="HOEnZb"><div class="h5"><br>
-- <br>
Maxim Dounin<br>
<a href="http://mdounin.ru/" rel="noreferrer" target="_blank">http://mdounin.ru/</a><br>
______________________________<wbr>_________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/<wbr>mailman/listinfo/nginx</a><br>
</div></div></blockquote></div><br></div>