页次: 1
yum install haproxy -y
/usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg
配置文件haproxy.cfg:
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
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
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
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
frontend main
mode tcp
bind *:8081
log global
option tcplog
log-format %ft\ %b/%s
tcp-request inspect-delay 3s
acl is_https req.payload(0,3) -m bin 160301
#GET POS(T) PUT DEL(ETE) OPT(IONS) HEA(D) CON(NECT) TRA(CE)
acl is_http req.payload(0,3) -m bin 474554 504f53 505554 44454c 4f5054 484541 434f4e 545241
#SSH
acl is_ssh req.payload(0,3) -m bin 535348
tcp-request content accept if is_http
tcp-request content accept if is_https
tcp-request content accept if is_ssh
tcp-request content accept
use_backend https if is_https
use_backend http if is_http
use_backend ssr if is_ssh
use_backend ssr
backend ssr
mode tcp
timeout server 1h
server server-ssh 127.0.0.1:61000
backend http
mode tcp
server ngx01 127.0.0.1:80 maxconn 10 check inter 3s
backend https
mode tcp
server ngx02 127.0.0.1:433 maxconn 10 check inter 3s
离线
页次: 1