1

I want to distribute traffic in an nginx reverse proxy across upstreams based on a string that's present in a header, but do so both deterministically and performantly. Situation-wise, think something like a cellular routing setup. In order to do this, I'm thinking I'd hash this string and project that hash into an n-space (where n is the number of upstreams). This would give a consistent and 'sticky' connection routing setup across our fleet of reverse proxies.

If possible I'd like to avoid adding modules to my build, but if it's unavoidable so be it. I know that njs, lua, etc modules could provide this for us, for instance.

It'd be great if I could do something like

set $destination_hash hash_of $http_my_header;

I realize this is pushing the limits of 'configuration' and is more like application logic, but it seems config-y enough in the context of cellular routing that I figured I'd ask. If the answer is that only a lua/perl/js module will work, then so be it. If that is the case, examples or references would be appreciated too :)

a p
  • 121
  • 1
  • 8

0 Answers0