<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/......./">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<br></div><div>Eswar<br></div><div><br></div></div>