use the http_perl_module to development a simple url hash module

Changliang Chen hqucocl at gmail.com
Tue Dec 25 11:38:15 MSK 2007


Hmm,what's your question?

2007/12/25, 焦胜强 <jiaosq at mail.51.com>:
>
>         perl_set $backend '
>                 sub {
>                         use Digest::MD5 (md5_hex);
>                         my $r = shift;
>                         my $uri = $r->uri;
>                         @arr = qw( 192.168.1.2 192.168.1.3 192.168.1.4
> 192.168.1.5);
>                         $arr_num = $#arr + 1;
>                         $url = substr(md5_hex($uri), -8);
>                         $backend = $arr[hex($url) % $arr_num];
>                         return $backend;
>                 }
>         ';
>
> location / {
>         proxy_pass http://$backend$request_uri;
> }
>



-- 
Best Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20071225/cac8eaaf/attachment.html>


More information about the nginx mailing list