use the http_perl_module to development a simple url hash module
焦胜强
jiaosq at mail.51.com
Tue Dec 25 09:14:44 MSK 2007
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;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20071225/9c021c3f/attachment.html>
More information about the nginx
mailing list