I am wondering if it is possible to compute some kind of hash value from
ip
address or do modulo operation on the last numeric value from ip address
(for example on 24 given 172.16.4.24)? Based on this, I want to send the
request to different endpoints (not to different servers). If this can
be
done without installing any new module, that would be the best.
As far as I can see, I feel like I should do something similar using the
regex?
I am wondering if it is possible to compute some kind of hash value
from ip address or do modulo operation on the last numeric value from
ip address (for example on 24 given 172.16.4.24)? Based on this, I
want to send the request to different endpoints (not to different
servers). If this can be done without installing any new module, that
would be the best.
As far as I can see, I feel like I should do something similar using
the regex?
Yes, regex and map should help. If you want to derive four distinct
values,
you can do something like this:
I have no idea if the fourth IP byte is normally distributed. If not,
then
may generate a full mapping (~.1$, ~.2$, … ~.10$, …, ~.99$, …,
~.255$)
If you want to do something even more fancy you can go totally binary
with
the $binary_remote_addr variable and \xYY in the regexp (never tried
this as
it is more difficult to debug).
Oliver
Posted at Nginx Forum:
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.