Difference between revisions of "Haproxy"
From Notes_Wiki
(Created page with "<yambe:breadcrumb>Network_related_tools|Network tools</yambe:breadcrumb> =haproxy= haproxy can be used for load-balancing among different backend servers. If servers are web...") |
m |
||
Line 22: | Line 22: | ||
#:::</pre> | #:::</pre> | ||
#::::Here the IP in first line should be IP address of haproxy server. The IPs in the server lines are the IP addresses of backend servers. This particular configuration load balances port 8080 of haproxy to port 80 of backend servers. The port numbers can be changed to some other suitable value based on the application. Apart from "mode tcp" other option is "mode http" for http servers. Apart from "balance roundrobin" other option is to use "balance source" so that same source IP is always sent to the same backend server. | #::::Here the IP in first line should be IP address of haproxy server. The IPs in the server lines are the IP addresses of backend servers. This particular configuration load balances port 8080 of haproxy to port 80 of backend servers. The port numbers can be changed to some other suitable value based on the application. Apart from "mode tcp" other option is "mode http" for http servers. Apart from "balance roundrobin" other option is to use "balance source" so that same source IP is always sent to the same backend server. | ||
<yambe:breadcrumb>Network_related_tools|Network tools</yambe:breadcrumb> |
Revision as of 08:47, 9 September 2018
<yambe:breadcrumb>Network_related_tools|Network tools</yambe:breadcrumb>
haproxy
haproxy can be used for load-balancing among different backend servers. If servers are web-servers then haproxy can do more intelligent balancing based on sessions, etc. To configure haproxy for load-balancing requests to backend servers use following steps:
- Configure all repositories (rpmfusion, repoforge, epel, etc.)
- yum -y install haproxy
- Edit /etc/haproxy/haproxy.cfg and comment following lines
- option httplog
- option dontlognull
- option http-server-close
- option forwardfor except 127.0.0.0/8
-
- as these are related to http. Then remove or comment all existing lines for various frontend and backend servers. Then create simple configuration such as
- listen test1 192.168.122.103:8080
- mode tcp
- balance roundrobin
- server web1 192.168.122.104:80 weight 1 maxconn 512 check
- server web2 192.168.122.105:80 weight 1 maxconn 512 check
-
- Here the IP in first line should be IP address of haproxy server. The IPs in the server lines are the IP addresses of backend servers. This particular configuration load balances port 8080 of haproxy to port 80 of backend servers. The port numbers can be changed to some other suitable value based on the application. Apart from "mode tcp" other option is "mode http" for http servers. Apart from "balance roundrobin" other option is to use "balance source" so that same source IP is always sent to the same backend server.
- as these are related to http. Then remove or comment all existing lines for various frontend and backend servers. Then create simple configuration such as
<yambe:breadcrumb>Network_related_tools|Network tools</yambe:breadcrumb>