Wednesday, 2 May 2018

Apache httpd load balancer setup


Install httpd as service by following  http://httpd.apache.org/docs/2.4/install.html 

sudo yum install httpd
sudo systemctl enable httpd
sudo systemctl start httpd

1) Edit /etc/httpd/conf/httpd.conf and change the Listen port to configure the Load balancer port. By default port will be 80.

2) Add a file lb.conf under /etc/httpd/conf.d to configure members to be redirected. httpd service will load all *.conf files present under /etc/httpd/conf.d folder.

3) lb.conf content example as below.

ProxyRequests off
<Proxy balancer://Testbalancer>
BalancerMember <URL1>
BalancerMember <URL2>
BalancerMember <URL3>
ProxySet lbmethod=byrequests Or ProxySet lbmethod=bybusyness Or lbmethod=bytraffic
</Proxy>
<Location /balancer-manager>
SetHandler balancer-manager
</Location>
ProxyPass /balancer-manager !
ProxyPass / balancer://Testbalancer/ connectiontimeout=30 timeout=60


This will redirect all request http://<host>/ to either <URL1> or <URL2> or <URL3>

4) You can configure ProxyPass to redirect in case some specific string comes after the URL.

    ProxyPass "/test" balancer://Testbalancer/ connectiontimeout=30 timeout=60

    ProxyPassMatch "^/(.*\.gif)$" "http://backend.example.com/$1"

This will cause a local request for http://example.com/foo/bar.gif to be internally converted into a proxy request to http://backend.example.com/foo/bar.gif.

    ProxyPassMatch "^/(.*\.gif)$" "http://backend.example.com:8000/$1"


Start/Stop/Restart  service by : service httpd start/stop/restart






No comments:

Post a Comment

Thank You for your valuable comment

Difference between class level and object locking and static object lock

1) Class level locking will lock entire class, so no other thread can access any of other synchronized blocks. 2) Object locking will lo...