Thursday 12 March 2015

Pound Load balancer


Pound is a reverse proxy load balancer.   
What pound offers?
a. Pound is a reverse proxy : Pound acts as a wall between client and all your servers. It passes requests from client to one/more back end servers.
b. Pound is a load balancer : Pound is a load balancer, that distributes traffic across number of servers.
c. Pound acts as SSL wrapper : Pound will decrypt HTTPS requests from client browsers and pass them as plain HTTP to the back-end servers.
d. Pound will verify requests for correctness and accept only well-formed ones.
e. If any server fails, pound make a note of that server and stop forwarding requests to that server.


How to install pound in ubuntu
Open the terminal and run the following command 
          sudo apt-get install pound
 
Pound configuraion
pound configuration file is located in “/etc/pound/pound.cfg”.Open pound.cfg file.
 
Step 1 : We'll need delete all the content within ListenHTTP block, once done it should look like below.
ListenHTTP
End 


Step 2: Now we add an address and port to listen on and finally a line to remove an HTTP header. After adding port and address file looks like below.

ListenHTTP
Address 0.0.0.0
Port 80
HeadRemove "X-Forwarded-For"
End

Step 3 : Add the servers. Servers are added in BackEnd block.
ListenHTTP
Address 0.0.0.0
Port 80
HeadRemove "X-Forwarded-For"

Service
BackEnd
Address 192.168.1.110
Port 8080
Priority 1
End
BackEnd
Address 192.168.1.106
Port 8080
Priority 1
End
End
End


Step 4: Open file “/etc/default/pound”. Change from startup=0 to startup=1. Before doing this, Pound will refuse to start. 

Step 5 : Start pound : “/etc/init.d/pound start”
 
Note :
1. If you got error like “pound.cfg line 35: unknown directive – aborted”, make sure your editing is correct. Did you edit your pound config file on DOS/Windos? If yes then maybe your config file has CRLF line ends but *X systems want only LF.

Final pund.cfg looks like below.


## Minimal sample pound.cfg 
## 
## see pound(8) for details 


###################################################################### 
## global options: 

User            "www-data" 
Group           "www-data" 
#RootJail       "/chroot/pound" 

## Logging: (goes to syslog by default) 
##      0       no logging 
##      1       normal 
##      2       extended 
##      3       Apache-style (common log format) 
LogLevel        1 

## check backend every X secs: 
Alive           30 

## use hardware-accelleration card supported by openssl(1): 
#SSLEngine      "<hw>" 
 
# poundctl control socket 
Control "/var/run/pound/poundctl.socket" 


###################################################################### 
## listen, redirect and ... to: 

## redirect all requests on port 8080 ("ListenHTTP") to the local webserver (see "Service" below): 
ListenHTTP 
Address 0.0.0.0 
Port 80 
HeadRemove "X-Forwarded-For" 

Service 
BackEnd 
Address 192.168.1.110 
Port 8080 
Priority 1 
End 
BackEnd 
Address 192.168.1.106 
Port 8080 
Priority 1 
End 
End 
End 





 



No comments:

Post a Comment