HAProxy的压缩功能

haproxy还支持http协议的压缩机制,常用的算法有gzip和deflate。 压缩的功能仅在7层有效,用户在请求时会先将浏览器支持的压缩算法发送给服务器,然后使用相同的压缩算法将数据返回给用户

压缩的使用方法

1.修改配置文件

frontend web
 bind 172.20.27.20:80
 mode http     #haproxy要启用压缩功能必须是在7层 
 compression algo gzip deflate  #开启压缩功能及所支持的压缩格式
 compression type text/plain text/html text/css text/xml text/javascript            #压缩的类型
 use_backend web_server
backend web_server
 server web1 192.168.27.21 check port 80 inter 3s fall 3 rise 5
 server web1 192.168.27.22 check port 80 inter 3s fall 3 rise 5

2.测试