Remember in a previous article introduced the Nginx reverse proxy https method, here today to introduce the next Haproxy proxy https method:
There are two ways of Haproxy proxy https:
1) The Haproxy server itself provides the SSL certificate, the following Web server goes normal http
2) Haproxy server itself only provides proxy, the following Web server goes HTTPS (Configure SSL certificate)
The first way: the Haproxy server itself provides an SSL certificate
Attention:
SSL is supported when compiling haproxy is required
Compile parameters:
#make target=linux26 use_openssl=1 Addlib=-lz
#ldd Haproxy | grep SSL
libssl.so.10 =/usr/lib64/libssl.so.10 (0x00007fb0485e5000)
Configuration parameters (Modify Haproxy.cfg file)
Frontend https_frontend
Bind *:443 SSL Crt/etc/ssl/certs/servername.pem
Mode http
Option Httpclose
Option Forwardfor
Reqadd x-forwarded-proto:\ HTTPS
Default_backend Web_server
Backend Web_server
Mode http
Balance Roundrobin
Cookie ServerID Insert Indirect nocache
Server S1 192.168.1.150:80 Check cookie s1
Server s2 192.168.1.151:80 Check cookie s2
-----------------------------------------------------------
Note: The Pem file here is a combination of the following two files:
#cat servername.crt Servername.key |tee Servername.pem
-----------------------------------------------------------
The second way: the Haproxy server itself only provides the proxy, no SSL certificate (generally we commonly used this way)
This way, Haproxy does not need to recompile to support SSL, simple and convenient, only need to configure the following Web server SSL.
Configuration parameters (Modify Haproxy.cfg file)
Frontend https_frontend
Bind *:443
Mode TCP
Default_backend Web_server
Backend Web_server
Mode TCP
Balance Roundrobin
Stick-table Type IP size 200k expire 30m
Stick on SRC
Server S1 192.168.1.150:443
Server S2 192.168.1.151:443
---------------------------------------------------------
Note that mode must be in the TCP mode
---------------------------------------------------------
Haproxy Proxy HTTPS Configuration method