//
you're reading...
Apache, High Availability, howto, Load Balancing, OpenSource, Solutions

Using Pen, mod_rewrite and mod_proxy Apache modules to perform selective url based loadbalancing/fail-over with “n” backend servers

1.Download Pen through the following link ;

http://siag.nu/pen/

2.raise the file descriptor limits by editing the /usr/include/linux/posix_types.h and /usr/include/bits/typesizes.h as follows ;

change :
#define __FD_SETSIZE 1024

to :
#define __FD_SETSIZE 10240

and then compile Pen

3. Launch Pen as follows;
./pen -x 5000 -d -d -f 8280 server1:8280 server2:8280

4. Apache Configuration
RewriteEngine on
RewriteLog logs/proxy_rewrite.log
RewriteLogLevel 9
RewriteCond %{REQUEST_URI} ^/cs/.*
RewriteCond %{QUERY_STRING} .*(childpagename=blabla).*
RewriteCond %{QUERY_STRING} !(binary=true)
RewriteRule ^/cs/.* http://localhost:8280/myurl1/myurl2$1 [P]

ProxyPass /cs http://nlb:8080/cs
ProxyPassReverse /cs http://nlb:8080/cs


the following apache configuration can be also used alternately without pen.

RewriteEngine on
RewriteLog logs/proxy_rewrite.log
RewriteLogLevel 9
RewriteMap server rnd:conf/balance.conf
RewriteCond %{REQUEST_URI} ^/cs/.*
RewriteCond %{QUERY_STRING} .*(childpagename=blabla).*
RewriteCond %{QUERY_STRING} !(binary=true)
RewriteRule ^/cs/.* http://${server:FIRST}/myurl1/myurl2$1 [P]

# cat balance.conf
FIRST server1:8280|server2:8280
#

Discussion

Comments are closed.

%d bloggers like this: