Nginx load balancing based on URL and not IP address

load balancingnginx

We have concerns about load balancing based on IP for our service (for instance, a mobile client switching from 3G to Wifi). Is there a way to do it based on a part of a URL instead of by IP hash?

Best Answer

Use the Upstream Consistent Hash module:

http://wiki.nginx.org/HttpUpstreamConsistentHash

or Upstream Request Hash Module:

http://wiki.nginx.org/NginxHttpUpstreamRequestHashModule