实际生产环境中架构用到IIS+haproxy+keepalived+nginx,需要综合整理学习一下。

    折腾半天haproxy,大面上配通,细节上还有很多需要整理。

环境:
    前端:haproxy  IP:192.168.71.128
    后端WEB:
    server01:apache  192.168.71.138(Linux)
    

    server02:apache  192.168.71.135(windows)

    

试验目的:

    前端haproxy为后端两台Web服务器做负载均衡及灾备冗余。

2015-1-31

##############################################

1.vim /etc/rsyslog.conf

local2*   /var/log/haproxy.log

2.vim /etc/sysconfig/rsyslog

SYSLOGD_OPTIONS="-c 2"

service rsyslog restart

3.vim /etc/haproxy/haproxy.conf

global

    log         127.0.0.1 local2

    chroot      /var/lib/haproxy

    pidfile     /var/run/haproxy.pid

    maxconn     40000

    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

listen stats

mode http

bind *:1080

stats enable

stats hide-version

stats uri /haproxyadmin?stats

stats realm Haproxy\ Statistics

stats auth admin:admin

stats admin if TRUE

frontend web

bind *:8080

mode http

log global

option logasap

option dontlognull

capture request header Host len 20

capture request header Referer len 60

default_backend servers

backend servers

balance roundrobin

server websvr1 219.142.x.x:80 check maxconn 2000

server websvr2 219.142.x.x:80 check maxconn 2000