httpd.conf fragment
DocumentRoot /var/www/domains/hausfoundation.org/archive/htdocs/current/public RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f RewriteMap lb "prg:/usr/local/bin/load-balancer ror.archive.hausfoundation.org 8000 8002" RewriteRule ^/(.*)$ ${lb:$1} [P,L]
load-balancer script
#!/usr/bin/env perl $| = 1; $name = $ARGV[0]; # the hostname base $first = $ARGV[1]; # the first port in the round-robin $last = $ARGV[2]; # the last port in the round-robin $cnt = 0; $num = $last - $first + 1 while (<STDIN>) { $server = sprintf("%s:%d", $name, $cnt+$first); $cnt = (($cnt+1) % ($num)); print "http://$server/$_"; }
