apisix-开启gzip
针对路由开启gzip插件
如果config.yaml里面开启了plugins
那么要添加一下gzip插件, 重启一下apisix
cd /usr/local/apisix/conf && vim config.yaml
plugins:
- gzip
apisix restart
插件的启用与关闭
TOKEN=edd1c9f034335f136f87ad84b625c8f1
GATEWAY_DOMAIN=http://192.168.1.164:9080
ID=9
# 开启路由的gzip插件
curl $GATEWAY_DOMAIN/apisix/admin/routes/$ID -H "X-API-KEY: $TOKEN" -X PATCH -i -d '
{
"plugins": {
"gzip": {}
}
}'
# 关闭
curl $GATEWAY_DOMAIN/apisix/admin/routes/$ID -H "X-API-KEY: $TOKEN" -X PATCH -i -d '
{
"plugins": {
"gzip": null
}
}'
修改apisix的nginx配置开启gzip
cd /usr/local/apisix/conf && vim config.yaml
apisix restart
nginx_config:
http_configuration_snippet: |
gzip on;
gzip_comp_level 3;
gzip_buffers 320 320k;
gzip_min_length 4096;
gzip_types text/plain text/style application/javascript application/x-javascript text/javascript text/css application/json;
生成后的nginx.conf