按照Centos7 haproxy1.7 安装haproxy,
然后在我的haproxy.cfg中添加bind :9091 ssl crt /application/ca/server-cert.pem crt /etc/cert/certdir/
的配置,启动服务的时候,提示异常
global
#设置日志
log 127.0.0.1 local3 info
chroot /usr/local/haproxy
#用户与用户组
user root
group root
#守护进程启动
daemon
#最大连接数
maxconn 4000
#默认配置
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
#前端配置,http_front名称可自定义
frontend http_back
# 发起http请求道80端口,会被转发到设置的ip及端口
bind *:80
#haproxy的状态管理页面,通过/haproxy?stats来访问
stats uri /haproxy?stats
default_backend http_back
#后端配置,http_back名称可自定义
backend http_back
#负载均衡方式
#source 根据请求源IP
#static-rr 根据权重
#leastconn 最少连接者先处理
#uri 根据请求的uri
#url_param 根据请求的url参数
#rdp-cookie 据据cookie(name)来锁定并哈希每一次请求
#hdr(name) 根据HTTP请求头来锁定每一次HTTP请求
#roundrobin 轮询方式
balance roundrobin
#设置健康检查页面
#option httpchk GET /index.html
#传递客户端真实IP
option forwardfor header X-Forwarded-For
# inter 2000 健康检查时间间隔2秒
# rise 3 检测多少次才认为是正常的
# fall 3 失败多少次才认为是不可用的
# weight 30 权重
# 需要转发的ip及端口
server node1 192.168.4.187:8093 check inter 2000 rise 3 fall 3 weight 30
frontend thrift_front
bind :9091 ssl crt /application/ca/server-cert.pem crt /etc/cert/certdir/
mode tcp
log global
option tcplog
timeout client 3600s
backlog 4096
maxconn 50000
default_backend thrift_back
backend thrift_back
mode tcp
option log-health-checks
option redispatch
option tcplog
balance roundrobin
timeout connect 1s
timeout queue 5s
timeout server 3600s
server s1 192.168.4.187:9091 check
详细异常信息如下:
[root@ceshi185 haproxy]# service haproxy start
[ALERT] 121/164316 (38066) : parsing [/etc/haproxy/haproxy.cfg:56] : 'bind *:9091' unknown keyword 'ssl'. Registered keywords :
[STAT] level <arg>
[ TCP] defer-accept
[ TCP] interface <arg>
[ TCP] mss <arg>
[ TCP] transparent
[ TCP] v4v6
[ TCP] v6only
[UNIX] gid <arg>
[UNIX] group <arg>
[UNIX] mode <arg>
[UNIX] uid <arg>
[UNIX] user <arg>
[ ALL] accept-netscaler-cip <arg>
[ ALL] accept-proxy
[ ALL] backlog <arg>
[ ALL] id <arg>
[ ALL] maxconn <arg>
[ ALL] name <arg>
[ ALL] nice <arg>
[ ALL] process <arg>
[ALERT] 121/164316 (38066) : Error(s) found in configuration file : /etc/haproxy/haproxy.cfg
[ALERT] 121/164316 (38066) : Fatal errors found in configuration.
Errors found in configuration file, check it with 'haproxy check'.
执行命令haproxy -vv
这个意思是我安装的时候并没有使用openssl,
解决方案参考Haproxy with SSL doesn’t works
重新安装haproxy,关键是下面的步骤,其余的按照 Centos7 haproxy1.7 安装来执行
tar -zxvf haproxy-1.7.5.tar.gz
ln -s haproxy-1.7.5 haproxy
cd haproxy
make TARGET=linux2628 USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1 USE_CRYPT_H=1 USE_LIBCRYPT=1
再次检查
再次执行命令sbin/haproxy -f conf/haproxy.conf
启动haproxy,提示异常
解决方案是将server-key.pem和server-cert.pem合在一个文件中
frontend thrift_front
bind :9091 ssl crt /application/ca/server.pem
mode tcp
log global
option tcplog
timeout client 3600s
backlog 4096
maxconn 50000
default_backend thrift_back
想看到haproxy的监控
#统计页面配置
listen admin
bind *:8888
mode http
stats enable
stats hide-version
stats uri /admin?status
stats auth ha:ha
stats refresh 5s
bind-process 2 #此行为上面加入到配置文件当中的