F5负载均衡系列教程三【SSL卸载实验,给定场景判断需要添加哪些profile】
实验拓扑如下,实验环境搭建参考https://www.cnblogs.com/romin/p/17825779.html
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222101404-18759247.png)
实验前提条件:
1、拥有类似拓扑一样的实验环境;
2、搭建简单的web服务器,比如上图的172.16.128.0、172.16.128.1、172.16.128.2三台服务器可以对外提供http和https服务
实验初始配置:
1、新建如下的pool和VS
注意,后续的实验可能会出现vs_https_10.1.10.129调用pool_http_10.1.10.129的情况,只是验证http和https需要使用哪些profile
172.16.128.0、172.16.128.1、172.16.128.2三台服务器对外提供http和https登录的页面一样,如下所示:
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222102663-1362095965.png)
实验一、验证https是否可以添加http profile(答案是不可以,如果SSL卸载不是在F5进行的话)
正常情况下,通过客户端访问vs_https_10.1.10.129,并对10.1.10.129的443端口进行抓包,抓包命令如下所示
tcpdump -nni 0.0 -s0 host 10.1.10.129 -vvv -w /var/tmp/romin-vs.pcap
可以发现,能打开服务器的对外服务页面
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222102663-1362095965.png)
抓包发现,数据是被加密了;因为数据被加密了,所以也无法使用irules根据http request进行分发
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222102656-1759349081.png)
修改vs_https_10.1.10.129使用http profile
抓包再次访问,发现访问失败,这说明在F5不对https流量进行解密的情况下,是不可以调用http profile的
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222104245-2056612812.png)
抓包可以发现,https的TLS协商都未完成,去掉http profile,恢复实验环境
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222104648-1792050009.png)
实验二、服务器对外提供https服务,F5对外提供http服务是否可行(可行,但是要添加server ssl profile)
将vs_http_10.1.10.129改成调用pool_https_10.1.10.129,然后访问http://10.1.10.129.,同时抓包
结果发现请求失败![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222104621-1247618593.png)
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222104621-1247618593.png)
抓包发现服务器返回了400状态码,所以这样子是行不通的
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222101159-1332758024.png)
在F5上调用系统默认的server ssl profile,刷新页面,发现可以正常打开页面
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222100658-178639267.png)
抓包的数据前端是http流量,后端是https流量
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222101230-971519125.png)
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222101327-1611057702.png)
实验三、验证服务器使用http服务,F5对外提供https业务是否可行(可行,但是要添加client ssl profile),添加了client ssl profile后,还可以添加http profile
新建一个https_vs_test,地址为10.1.10.132,对外提供443服务,但是调用pool_http_10.1.10.129
访问发现报错
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222101182-450651983.png)
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222101075-32692450.png)
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222101091-1068874532.png)
可以看到tls握手是失败的
添加client ssl profile后,发现可以打得开登录页面了
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222100976-205584949.png)
抓包的数据前端是https流量,后端是http流量
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222101309-497043723.png)
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222101186-2063427118.png)
恢复原本的配置,恢复实验环境
实验四、验证同时使用clent ssl profile和server ssl profile
访问vs_https_10.1.10.129,https://10.1.10.129发现前后端数据都是经过tls加密的
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222101082-627749614.png)
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222101098-648504741.png)
给vs_https_10.1.10.129同时添加上client ssl profile和server ssl profile,再次访问并抓包;虽然都是加密的,但是实际上F5以及对数据包进行解密,并重新加密,这样的话,F5就可以配置irules和cookie profile;同时也可以看到,和之前的tls协商的算法也有变化,没挂client ssl profile的时候,是不能使用http profile的,挂了后才能使用
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222101222-1713112479.png)
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222101301-1246034392.png)
实验五、在实验四的基础上,添加cookie persistence,并挂上http profile
添加一个cookie persistence
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222101251-704580563.png)
重置当前的pool 统计信息
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222101078-1200811688.png)
再次访问https://10.1.10.129,只访问一次同时抓包,可以看到数据分到了172.16.128.0这台服务器上,只要cookie相同,流量就会一直发到该设备上;这在一些购物网站上非常有用
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222101017-1397855306.png)
然后也可以看到,cookie是F5插入的
![0](https://img2023.cnblogs.com/blog/1519046/202311/1519046-20231115222100812-2016707080.png)
实验结论:
1、内网服务器提供http服务,对外使用https服务时,可以在F5上调用client ssl profile,但是证书建议用自己申请的;
2、若内网服务器提供https服务,F5还需要使用http profile和会话保持等功能,就要在F5上做SSL卸载,并添加client ssl profile和server ssl profile;