日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

配置HAProxy支持https协议

發(fā)布時(shí)間:2023/12/10 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 配置HAProxy支持https协议 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

author:JevonWei
版權(quán)聲明:原創(chuàng)作品


實(shí)現(xiàn)http重定向到https

HAProxy

創(chuàng)建CA證書 [root@HAProxy ~]# cd /etc/haproxy/ [root@HAProxy haproxy]# mkdir certs [root@HAProxy haproxy]# cd /etc/pki/CA [root@HAProxy CA]# (umask 077;openssl genrsa -out private/cakey.pem 4096) [root@HAProxy CA]# openssl req -new -x509 -key private/cakey.pem -out cacert.pem -days 365 \\自簽名證書 [root@HAProxy CA]# touch index.txt [root@HAProxy CA]# echo 01 > serial[root@HAProxy CA]# cd /etc/haproxy/certs/ [root@HAProxy certs]# openssl genrsa -out haproxy.key 2048 [root@HAProxy certs]# openssl req -new -key haproxy.key -out haproxy.csr [root@HAProxy certs]# [root@HAProxy certs]# openssl ca -in haproxy.csr -out haproxy.crt [root@HAProxy certs]# ls haproxy.crt haproxy.csr haproxy.key [root@HAProxy certs]# cat haproxy.crt haproxy.key > haproxy.pem [root@HAProxy certs]# ll total 12 -rw-r--r--. 1 root root 0 Aug 29 19:36 haproxy.crt -rw-r--r--. 1 root root 1009 Aug 29 19:35 haproxy.csr -rw-r--r--. 1 root root 1675 Aug 29 19:34 haproxy.key -rw-r--r--. 1 root root 1675 Aug 29 19:37 haproxy.pem [root@HAProxy certs]# chmod 600 haproxy.pem

配置haproxy網(wǎng)頁跳轉(zhuǎn)

[root@HAProxy ~]# vim /etc/haproxy/haproxy.cfgfrontend https *:443bind *:443 ssl crt /etc/haproxy/certs/haproxy.pemacl static path_end .jpg .jpeg .png .gif .txt .htmlacl static path_beg /imgs /images /cssuse_backend staticsrvs if staticdefault_backend dynsrvsfrontend httpbind *:8080redirect scheme https if !{ ssl_fc }backend dynsrvsbalance roundrobinserver dynsrv1 172.16.253.105:80 checkserver dynsrv2 172.16.253.105:8080 checkbackend staticsrvsbalance roundrobinserver staticsrv1 172.16.253.191:80 checkserver staticsrv2 172.16.253.191:8080 check [root@HAProxy ~]# systemctl restart haproxy

配置haproxy主頁跳轉(zhuǎn),即訪問的http的所有內(nèi)容都跳轉(zhuǎn)到https的默認(rèn)主頁上

[root@HAProxy ~]# vim /etc/haproxy/haproxy.cfgfrontend https *:443bind *:443 ssl crt /etc/haproxy/certs/haproxy.pemacl static path_end .jpg .jpeg .png .gif .txt .htmlacl static path_beg /imgs /images /cssuse_backend staticsrvs if staticdefault_backend dynsrvsfrontend httpbind *:8080redirect location https://172.16.253.108/ if !{ ssl_fc }backend dynsrvsbalance roundrobinserver dynsrv1 172.16.253.105:80 checkserver dynsrv2 172.16.253.105:8080 checkbackend staticsrvsbalance roundrobinserver staticsrv1 172.16.253.191:80 checkserver staticsrv2 172.16.253.191:8080 check [root@HAProxy ~]# systemctl restart haproxy

client訪問測(cè)試

轉(zhuǎn)載于:https://www.cnblogs.com/JevonWei/p/7468474.html

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)

總結(jié)

以上是生活随笔為你收集整理的配置HAProxy支持https协议的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。