<div dir="ltr"><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">As per <a href="http://nginx.org/en/docs/http/ngx_http_upstream_module.html#var_upstream_status">the docs</a>, it is said this variable contains all the status codes returned by each upstream interrogated.<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">From what I understood, server1 returned 504, server2 returned 502.<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">Those statuses are included in what the <a href="http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream">proxy_next_upstream</a> directive describes as an 'unsuccessful attempt', thus it seems every server of your upstream group has been tried (default number of attempts is 1 as per the <a href="http://nginx.org/en/docs/http/ngx_http_upstream_module.html#server">server</a> directive).<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">nginx then returned the result of the last attempt, resulting in a 502 answer passed back to the client.<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">I do not know what a 'special response' is. Custom header?<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">I also do not get why you are surprised by the fact 5xx responses end up with them being shown to client. They are perfectly valid HTTP status codes, indicating a server error, and are shown because no upstream server returned a 'successful' status code.<br></div><div class="gmail_extra"><div><div class="gmail_signature" data-smartmail="gmail_signature"><font size="1"><span style="color:rgb(102,102,102)">---<br></span><b><span style="color:rgb(102,102,102)">B. R.</span></b><span style="color:rgb(102,102,102)"></span></font></div></div>
<br><div class="gmail_quote">On Fri, Aug 19, 2016 at 9:54 PM, Frank Liu <span dir="ltr"><<a href="mailto:gfrankliu@gmail.com" target="_blank">gfrankliu@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I am using nginx as proxy with two upstream servers. In the access log, I log the upstream_address, upstream_status, status (downstream), a special response header from upstream, etc.</div><div><br></div><div>A few times I see in the log upstream_address: server1:port, server2:port with upstream_status: 504, 502 status: 502 special header: -</div><div>Since there is the special response header, I assume nginx didn't get any responses from either upstream servers. Why would upstream_status shows 504 and 502? Those code must not come from upstream, is it generated by nginx self? I thought it would be -, - since there are no upstream_status returned from upstream.</div><div><br></div><div>Thanks!</div><span class="HOEnZb"><font color="#888888"><div>Frank</div><div><br></div></font></span></div>
<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></blockquote></div><br></div></div>