<div dir="ltr">Thank you<div><br></div><div>But it seems not the solution I really want. The selected peer/server is calculated by config in upstream, such as 'hash $url consistent'.</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-05-18 14:07 GMT+08:00 Hung Nguyen <span dir="ltr"><<a href="mailto:hungnv@opensource.com.vn" target="_blank">hungnv@opensource.com.vn</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14px">Hello, </div><div style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14px"><br></div><div style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14px">I do not not think nginx has this feature, but we can do it with lua module, at it’s exactly what I did, you can find it here: <a href="https://github.com/whatvn/nginx_redirect_balancer" target="_blank">https://github.com/whatvn/nginx_redirect_balancer</a></div><div style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14px"><br></div><div><font face="Calibri,sans-serif"><u>I</u></font><u style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14px">t works with help of following awesome module by agentzh: </u><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.6px;background-color:rgb(247,247,247)">lua-nginx-module and lua-updstream-module </span></div><div><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.6px;background-color:rgb(247,247,247)"><br></span></div><div><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.6px;background-color:rgb(247,247,247)"><br></span></div><div><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.6px;background-color:rgb(244,244,244)">-</span></div><div><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.6px;background-color:rgb(241,241,241)">Hung</span></div><div><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.6px;background-color:rgb(241,241,241)"><br></span></div><div style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14px"><div></div></div></div><div style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14px"><br></div><span style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14px"><div style="font-family:Calibri;font-size:12pt;text-align:left;color:black;BORDER-BOTTOM:medium none;BORDER-LEFT:medium none;PADDING-BOTTOM:0in;PADDING-LEFT:0in;PADDING-RIGHT:0in;BORDER-TOP:#b5c4df 1pt solid;BORDER-RIGHT:medium none;PADDING-TOP:3pt"><span style="font-weight:bold">From: </span> nginx-devel <<a href="mailto:nginx-devel-bounces@nginx.org" target="_blank">nginx-devel-bounces@nginx.org</a>> on behalf of 洪志道 <<a href="mailto:hongzhidao@gmail.com" target="_blank">hongzhidao@gmail.com</a>><br><span style="font-weight:bold">Reply-To: </span> <<a href="mailto:nginx-devel@nginx.org" target="_blank">nginx-devel@nginx.org</a>><br><span style="font-weight:bold">Date: </span> Wednesday, May 18, 2016 at 12:35 PM<br><span style="font-weight:bold">To: </span> <<a href="mailto:nginx-devel@nginx.org" target="_blank">nginx-devel@nginx.org</a>><br><span style="font-weight:bold">Subject: </span> upstream/302<br></div><div><div class="h5"><div><br></div><div dir="ltr"><span style="font-size:14px">Hi</span><div style="font-size:14px"><br></div><div style="font-size:14px">Is there a way to get selected peer in upstream without sending request to backend server?</div><div style="font-size:14px"><br></div><div style="font-size:14px">upstream backend {</div><div style="font-size:14px"> hash $url consistent;</div><div style="font-size:14px"> server 192.168.1.101;</div><div style="font-size:14px"> server 192.168.1.102; # Assume this is selected</div><div style="font-size:14px"> server 192.168.1.103;</div><div style="font-size:14px">}</div><div style="font-size:14px"><br></div><div style="font-size:14px"><br></div><div style="font-size:14px">location /302 {</div><div style="font-size:14px"> proxy_pass <a href="http://backend/" target="_blank">http://backend</a>;</div><div style="font-size:14px"> # need other config or develop custom module?</div><div style="font-size:14px">}</div><div style="font-size:14px"><br></div><div style="font-size:14px"><br></div><div style="font-size:14px">> curl <a href="http://test.com/302" target="_blank">http://test.com/302</a> -v</div><div style="font-size:14px">...</div><div style="font-size:14px">Location: <a href="http://192.168.1.102/xxx" target="_blank">http://192.168.1.102/xxx</a></div><div style="font-size:14px">...</div><div style="font-size:14px"><br></div><div style="font-size:14px">Just get selected server, and i<span style="color:rgb(51,51,51);font-family:arial;font-size:13px;line-height:20.02px">mmediately</span> return for 302 location.</div><div style="font-size:14px">Is it possible to support the feature, or give me advices, thanks so much.</div></div></div></div>
_______________________________________________
nginx-devel mailing list
<a href="mailto:nginx-devel@nginx.org" target="_blank">nginx-devel@nginx.org</a>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a></span></div>
<br>_______________________________________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a><br></blockquote></div><br></div>