Skip to content

腾讯云 Nginx Ingress 启用 gzip

🏷️ TKE Nginx

修改 kube-system 命名空间下名为 {nginx-ingress-name}-ingress-nginx-controllerConfigMap ,在其中添加如下配置:

yaml
data:
  use-gzip: "true"

启用后请求响应中会有个 content-encoding: gzip 的标头。

附 1. 腾讯云服务默认的 Nginx Ingress 的 ConfigMap

yaml
apiVersion: v1
data:
  access-log-path: /var/log/nginx/nginx_access.log
  allow-snippet-annotations: "false"
  error-log-path: /var/log/nginx/nginx_error.log
  keep-alive-requests: "10000"
  log-format-upstream: $remote_addr - $remote_user [$time_iso8601] $msec "$request"
    $status $body_bytes_sent "$http_referer" "$http_user_agent" $request_length $request_time
    [$proxy_upstream_name] [$proxy_alternative_upstream_name] [$upstream_addr] [$upstream_response_length]
    [$upstream_response_time] [$upstream_status] $req_id
  max-worker-connections: "65536"
  upstream-keepalive-connections: "200"
kind: ConfigMap

参考链接