rancher里的ingress如何配置gzip压缩

方案一,未试验成功,但配置过程值得记录一下

通过配置configmap,然后在ingress的deployment里引用configmap实现。

参考文章

创建configmap

XML 复制代码
apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-ingress-controller
  annotations:
    {}
#    key: string
  creationTimestamp: '2024-03-12T01:53:01Z'
  labels:
    {}
#    key: string
  namespace: ingress-nginx
  resourceVersion: '101812971'
  uid: afe0261e-848a-4af3-a3fd-e0260dd226fd
  fields:
    - nginx-ingress-controller
    - 1
    - 89m
data:
  server-snippet: >
    use-gzip: true
  
    gzip-level: 5
  
    gzip-types: "application/xml+rss application/atom+xml application/javascript
    application/x-javascript application/json applica-tion/rss+xml
    application/vnd.ms-fontobject application/x-font-ttf
    application/x-web-app-manifest+json application/xhtml+xml application/xml
    font/opentype image/svg+xml image/x-icon text/css text/javascript text/plain
    text/x-com-ponent"
#  key: string
__clone: true
#binaryData:
#  key: string
#immutable: boolean

在ingress的定义里,引用configmap

在环境变量里

配置后,通过观察浏览器里的输出,response并没有gzip,js文件的大小也没变。试验失败。

方案二,试验成功了

在发布前端的docker里的nginx里写gzip配置

直接写gzip配置即可

bash 复制代码
server {
    
    listen      80 default_server;
    #listen      [::]:80;
    server_tokens off;
    server_name _;
    client_max_body_size 0;
    underscores_in_headers on;

    gzip on;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    #gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_types text/plain application/x-javascript application/javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_vary off;
    gzip_disable "MSIE [1-6]\.";
相关推荐
Ashmcracker11 小时前
导入Azure AKS集群到Rancher
microsoft·kubernetes·rancher·azure
ascarl201013 小时前
rancher查看日志:failed to create fsnotify watcher: too many open files
rancher
阿杰 AJie14 小时前
Nginx配置静态资源服务器
运维·服务器·nginx
sunnyday042617 小时前
Nginx与Spring Cloud Gateway QPS统计全攻略
java·spring boot·后端·nginx
何以不说话17 小时前
zabbix部署及nginx的监控
运维·nginx·zabbix
bukeyiwanshui18 小时前
Nginx 服务器
运维·服务器·nginx
jc062018 小时前
项目实战6-消息推送
c++·redis·websocket·nginx·kafka
weixin_4624462318 小时前
一台电脑模拟多节点 Kubernetes 集群:Kind 实战教程(含 Nginx 测试)
nginx·kubernetes·kind
weixin_4624462318 小时前
在宝塔 Nginx 上安装与配置 lua-cjson 教程
nginx·junit·lua
米高梅狮子19 小时前
06. Nginx 服务器
运维·服务器·nginx