<div dir="ltr"><div><div><div>Hi Antonio,<br><br></div>Thanks for the response.<br><br></div><div>I am unable to understand your solution.<br><br></div><div>As I said, I am unable to know which server served the requests to respective customer-id.<br>
</div><div>So I cant write the below map directive.<br>map $customer_id $sticky_backend {<br> default bad_gateway;<br> <cust-id_1> <server 1>;<br> <cust-id_2> <server 2>;<br>}<br></div><div><br>
</div>Thanks<br></div>Eswar<br><div><div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 29, 2013 at 2:31 PM, António P. P. Almeida <span dir="ltr"><<a href="mailto:appa@perusio.net" target="_blank">appa@perusio.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>You chain two map directives. Like this:<br><br></div><div>map $uri $customer_id {<br>
</div><div> ~/customer/(?<cust_id>[^/]+)/.*$ $cust_id;<br></div><div class="im"><div><br>}<br></div><div><br>map $customer_id $sticky_backend {<br>
default bad_gateway;<br> <cust-id_1> <server 1>;<br> <cust-id_2> <server 2>;<br>} <br><br></div></div></div><div class="gmail_extra"><span class=""><font color="#888888"><br clear="all"><div>
----appa<br><br></div>
<br><br></font></span><div class="gmail_quote"><div><div class="h5">On Mon, Apr 29, 2013 at 8:27 AM, ESWAR RAO <span dir="ltr"><<a href="mailto:eswar7028@gmail.com" target="_blank">eswar7028@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="h5">
<div dir="ltr"><div><div><div><div><div><div>Hi All,<br><br></div>Can anyone please help me with the below requirement.<br><br></div>Host machine contains a plugin and it communicates with a plugin handler running on backend servers and nginx is used to load balance the requests.<br>
<br></div>host machine(plugin) ===== >nginx as load balancer =====>3 backend servers which hosts plugin handler<br><br></div>I need to load balance the requests based on customer-id field in host machine.<br># curl '<a href="http://localhost:8031/test1/test2/test3/customer/123456789999999999/......./" target="_blank">http://localhost:8031/test1/test2/test3/customer/123456789999999999/......./</a><br>
<br></div>customer-id: 123456789999999999<br></div><div>customer-id changes with customers.<br></div><div><br></div><div>Since the requests come from same machine, I can't use ip_hash or cookie based load balancing technique.<br>
<br></div><div>My requirement is to load balance according to customer id and if same request comes the same customer it should go to same earlier server which served the request.<br><br><br></div><div>I am planning to extract the customer-id in nginx configuration file and add them on the fly in the config file and compare the ids using "map" directive. But unable to know which server served the requests to customer-id:<br>
<br>map $customer_id $sticky_backend {<br> default bad_gateway;<br> <cust-id_1> <server 1>;<br> <cust-id_2> <server 2>;<br>}<br> if ( $request_uri ~ ^/(.*)/(customer)/(.*?)/(.*)/ ) {<br></div>
<div> set $customer_id $3;<br><br></div><div>Thanks<span><font color="#888888"><br></font></span></div><span><font color="#888888"><div>Eswar<br></div><div><br></div></font></span></div>
<br></div></div><div class="im">_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br></div></blockquote></div><br></div>
<br>_______________________________________________<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" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br></blockquote></div><br></div></div></div></div></div></div>