Getting the time or client ip address

Fred Palmer fred at studionow.com
Tue Aug 14 17:45:39 MSD 2007


Igor,

Thanks for the idea, however going into the embedded Perl module is
not really an option for our installation of Nginx.  Can you recommend
another method to retrieve a pseudo-random number upon each request to
serve as a numbered variable?  A number between 1-100 would be
perfect.  We want to just serve up different versions of our home page
without going through the proxy to apache.  The idea is to have
version of the homepage named something like home_001.html,
home_002.html, home_003.html or something similar.

Thanks,
Fred

On 8/11/07, Igor Sysoev <is at rambler-co.ru> wrote:
> On Sat, Aug 11, 2007 at 05:00:04PM +0000, Fred Palmer wrote:
>
> > I want to write a rewrite rule that will serve a file based on a pseudo-random
> > variable such as time or client ip address.
> >
> > Is there a way to set that to a variable?
>
> http {
>
>     perl_set  $name  '
>
>         sub {
>             my $r = shift;
>             my $a = $r->remote_addr;
>
>             # any perl code changing $a
>
>             return $a;
>         }
>
>     ';
>
>
>     server {
>         ...
>
>         location = /some_file {
>             alias    /path/to/file/$name;
>         }
>
>         # or
>
>         location / {
>             rewrite   ...   ...$name... break;
>         }
>
>
> --
> Igor Sysoev
> http://sysoev.ru/en/
>
>


-- 
Fred Palmer | Senior Software Engineer
615.653.7228 | www.studionow.com





More information about the nginx mailing list