Haproxy implements port 80 multiplexing and haproxy80 multiplexing
Copyright:
The author of this article is-Chen Xin
All the content in this article is summarized by Chen Xin. Unauthorized forwarding and use are prohibited without my permission.
QQ:499741233
E-mail:499741233@qq.com
Chapter 2 installation environment 1st System Environment
[Root @ 10 conf] # uname-r
2.6.32-642.4.2.el6.x86 _ 64
[Root @ 10 conf] # uname-m
X86_64
[Root @ 10 conf] # cat/etc/re
Readahead. conf redhat-lsb/redhat-release request-key.conf request-key.d/resolv. conf
[Root @ 10 conf] # cat/etc/redhat-release
CentOS release 6.8 (Final)
1.2 program version 1.2.1 Haproxy
[Root @ 10 haproxy] #./sbin/haproxy-v
HA-Proxy version 1.5.11 2015/01/31
Copyright 2000-2015 Willy Tarreau <w@1wt.eu>
1.2.2 Haproxy Program
Chapter 4 Haproxy installation start 2nd Haproxy Installation
Tar xf haproxy-1.5.11.tar.gzcd haproxy-1.5.11make TARGET = linux26 PREFIX =/usr/local/haproxymake install PREFIX =/usr/local/haproxy Note: TARGET kernel version of the system to be specified.
2.2 Haproxy configuration file
cd /usr/local/haproxy/mkdir confcd confvim haproxy.cfg[root@10 conf]# cat haproxy.cfgglobal 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 *:80 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 ssh if is_ssh use_backend ssh backend ssh mode tcp timeout server 1h server server-ssh 127.0.0.1:22 backend http mode tcp server ngx01 127.0.0.1:82 maxconn 10 check inter 3s backend https mode tcp server ngx02 127.0.0.1:433 maxconn 10 check inter 3s
2.3 start Haproxy
useradd -s /sbin/nologin -M haproxymkdir /var/lib/haproxy/usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/conf/haproxy.cfg
Chapter 4 test 3rd test the ssh service
{17:05}~/login ➭ ssh root@10.63.101.52 -p80Last login: Thu Oct 13 17:05:27 2016 from localhost
3.2 Test the http service