1.yum安装
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
yum install -y haproxy
2.配置文件
vi /etc/haproxy/haproxy.cfg
3.配置查看状态网址
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
#查看状态网址
stats uri /haproxy-stats
4.配置监听端口:
#前端监听端口,及后端代理配置
frontend main *:80
acl url_static path_beg -i /static /images /javascript /stylesheets
acl url_static path_end -i .jpg .gif .png .css .js
use_backend static if url_static
default_backend app
5.后端配置
#静态文件配置
backend static
#轮询
balance roundrobin
server static 127.0.0.1:4331 check
#默认配置
backend app
#健康状态检测
option httpchk HEAD /index.html HTTP/1.0
balance roundrobin
server app1 192.168.1.102:80 check
server app2 192.168.1.105:80 check
Haproxy 配置项\配置实例
参考文章:http://www.cnblogs.com/dkblog/archive/2012/03/13/2393321.html
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
yum install -y haproxy
2.配置文件
vi /etc/haproxy/haproxy.cfg
3.配置查看状态网址
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
#查看状态网址
stats uri /haproxy-stats
4.配置监听端口:
#前端监听端口,及后端代理配置
frontend main *:80
acl url_static path_beg -i /static /images /javascript /stylesheets
acl url_static path_end -i .jpg .gif .png .css .js
use_backend static if url_static
default_backend app
5.后端配置
#静态文件配置
backend static
#轮询
balance roundrobin
server static 127.0.0.1:4331 check
#默认配置
backend app
#健康状态检测
option httpchk HEAD /index.html HTTP/1.0
balance roundrobin
server app1 192.168.1.102:80 check
server app2 192.168.1.105:80 check
Haproxy 配置项\配置实例
参考文章:http://www.cnblogs.com/dkblog/archive/2012/03/13/2393321.html
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30208512/viewspace-1578239/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/30208512/viewspace-1578239/