第一个:一般配置文件
~~~
#---------------------------------------------------------------------
# Example configuration for a possible web application. See the
# full configuration options online.
#
# http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
#
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
# to have these messages end up in /var/log/haproxy.log you will
# need to:
#
# 1) configure syslog to accept network log events. This is done
# by adding the '-r' option to the SYSLOGD_OPTIONS in
# /etc/sysconfig/syslog
#
# 2) configure local2 events to go to the /var/log/haproxy.log
# file. A line like the following can be added to
# /etc/sysconfig/syslog
#
# local2.* /var/log/haproxy.log
#
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
# turn on stats unix socket
stats socket /var/lib/haproxy/stats
#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
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
#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend main 10.2.13.220: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
option forwardfor except 127.0.0.1
option http-server-close
rspadd Via:\ proxy01.51yuki.cn
default_backend websrvs
#---------------------------------------------------------------------
# static backend for serving up images, stylesheets and such
#---------------------------------------------------------------------
#backend static
# balance roundrobin
# server static 127.0.0.1:4331 check
#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------
listen status
bind 10.2.13.220:8888
stats enable
stats hide-version
#stats scope .
stats uri /haproxyadmin?stats
stats realm Haproxy\ Statistics
stats auth statsadmin:Aa123456
stats admin if TRUE
backend websrvs
#balance hdr(User-Agent)
balance roundrobin
#hash-type consistent
mode http
#cookie SRV insert indirect nocache
appsession PHPSESSIONID len 64 timeout 5h request-learn
option httpchk HEAD /test3.html HTTP/1.1\r\nHost:\ test.51yuki.cn
server node7.51yuki.cn 192.168.20.132:8080 check inter 3000 rise 3 fall 3 weight 1
server node8:51yuki.cn 192.168.20.133:8080 check inter 3000 rise 3 fall 3 weight 2
server proxy01.51yuki.cn 192.168.20.131:8081 backup
~~~
第二个:基于虚拟主机的haproxy配置文件
~~~
global
log 127.0.0.1 local2 info
maxconn 4096
user haproxy
group haproxy
daemon
nbproc 1
pidfile /var/run/haproxy.pid
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
listen admin_stats
bind 0.0.0.0:19088
mode http
log 127.0.0.1 local3 err
stats refresh 30s
stats uri /haproxy-status
stats realm welcome login\ Haproxy
stats auth admin:xxxxx
stats auth admin1:xxxxx
stats hide-version
stats admin if TRUE
frontend website
bind *:80
mode http
option httplog
option forwardfor header X-Client
log global
acl host_www hdr_reg(host) -i ^(www.5yuki.cn|51yuki.cn)
acl host_www hdr_dom(host) -i bbs.51yuki.com
acl host_app hdr_beg(host) -i app.
use_backend server_www if host_www
use_backend server_bbs if host_bbs
use_backend server_app if host_app
default_backend server_default
backend server_default
mode http
option redispatch
blance roundrobin
cookie SERVERID insert nocache
option httpchk HEAD /test3.html HTTP/1.1\r\nHost:\ test.51yuki.cn
server node1 192.168.88.90:8000 cookie default1 weight 3 check inter 2000 rise 2 fall 3
server node2 192.168.88.91:8000 cookie default2 weight 3 check inter 2000 rise 2 fall 3
backend server_default
mode http
option redispatch
blance roundrobin
cookie SERVERID insert nocache
option httpchk HEAD /test3.html HTTP/1.1\r\nHost:\ test.51yuki.cn
server node1 192.168.88.90:8000 cookie default1 weight 3 check inter 2000 rise 2 fall 3
server node2 192.168.88.91:8000 cookie default2 weight 3 check inter 2000 rise 2 fall 3
backend server_www
mode http
option redispatch
blance roundrobin
cookie SERVERID insert nocache
option httpchk HEAD /test3.html HTTP/1.1\r\nHost:\ test.51yuki.cn
server www1 192.168.88.80:8080 cookie www1 weight 6 check inter 2000 rise 2 fall 3
server www2 192.168.88.81:8080 cookie www2 weight 6 check inter 2000 rise 2 fall 3
server www3 192.168.88.82:8080 cookie www3 weight 6 check inter 2000 rise 2 fall 3
backend server_bbs
mode http
option redispatch
blance roundrobin
cookie SERVERID insert nocache
option httpchk HEAD /test3.html HTTP/1.1\r\nHost:\ test.51yuki.cn
server bbs1 192.168.88.81:8080 cookie bbs1 weight 8 check inter 2000 rise 2 fall 3
server bbs2 192.168.88.82:8090 cookie bbs2 weight 8 check inter 2000 rise 2 fall 3
backend server_app
mode http
option redispatch
blance roundrobin
cookie SERVERID insert nocache
option httpchk HEAD /test3.html HTTP/1.1\r\nHost:\ test.51yuki.cn
server blog1 192.168.88.85:80 cookie blog1 weight 5 check inter 2000 rise 2 fall 3
server blog2 192.168.88.86:80 cookie blog2 weight 5 check inter 2000 rise 2 fall 3
~~~
- 第一章:集群理论介绍
- 第二章:共享存储
- 第一节:搭建基于 IP SAN 的 ISCSI 存储系统(在centos6系统)
- 第二节:基于openfiler搭建共享存储
- 第三章:高可用HA集群
- 第一节:Heartbeat高可用集群
- 第二节:corosync+pacemaker高可用nginx集群
- 第四章:反向代理(负载均衡)集群
- 第一部分:haproxy服务
- 第一节:haproxy基本介绍
- 第二节:在Centos7安装HAProxy
- 第三节: haproxy配置文件参数详解
- 第四节:haproxy+nginx+mysql+discuz
- 第五节:haproxy配置文件
- 第六节: Haproxy搭建全站ssl