Two new modules: random numbers and read cookies

Hi,

I just wrote two nginx modules we needed for using nginx in our load
balancing setup. Please have a look and give me feedback. I’d like to
add them to the wiki, but would like some feedback before I do. I based
them on existing modules as it was the easiest way to learn how to write
an nginx module. I used mod_rewrite as the starting point.

The modules are:

  1. mod-set-random
    ===============
    This module adds a new command for the nginx configuration file:
    set_random

To use it: set_random $some_random_var;

This will cause every reference to $some_random_var to return a random
number.
Please note that even in the same request different random numbers will
be
return for each reference! The random number return is in the range of
the
underlying OS rand() function.

I developed it to use in conjunction with the hash proxy module, to
allow
client stickiness from initial request until the client session ends.
See the README
for a full description and usage example.

  1. mod-read-cookies
    ================
    This module adds a new command for the nginx configuration file:
    set_from_cookie

To use it: set_from_cookie CookieName $some_var;

This will cause every reference to $some_var to return the value of the
cookie called CookieName. See the README for a full description and
usage example.

Though there is already a mod-parsed-vars, it requires patching nginx.
This module doesn’t
require any patch to work.

Enjoy!

Guy N.
CTO - Morph Labs
www.mor.ph

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs