From 51c94bccd77b4b67d68228e80b42e992b2cdee34 Mon Sep 17 00:00:00 2001 From: Ben Sully Date: Thu, 13 Jul 2023 07:51:25 +0100 Subject: [PATCH] api: ignore /api/gnet proxy when gzipping responses (#71437) This PR adds /api/gnet to the list of ignored paths in the gzip middleware. Without this, when gzip is enabled (`server.enable_gzip = true`), responses from the gnet proxy are double compressed: once by grafana.com and once by Grafana itself. With this change we only do one round of compression for these endpoints. To test this out, try a request like this with `server.enable_gzip = true` (after setting `GCOM_TOKEN` to a valid grafana.com token; you may need to change the 'bsull' slug, too): curl -v --user admin:admin \ -H "X-Api-Key: $GCOM_TOKEN" \ -H 'Accept-Encoding: gzip' \ localhost:3000/api/gnet/instances/bsull/provisioned-plugins/grafana-ml-app | gzip -d Note that there are two Content-Encoding: gzip headers before this PR, and the output is still compressed even after the `gzip -d`. After this PR things look as expected. --- pkg/middleware/gziper.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/middleware/gziper.go b/pkg/middleware/gziper.go index c72d14e18e2..02069695bf6 100644 --- a/pkg/middleware/gziper.go +++ b/pkg/middleware/gziper.go @@ -45,6 +45,7 @@ var gzipIgnoredPaths = []matcher{ prefix("/api/datasources"), prefix("/api/plugins"), prefix("/api/plugin-proxy/"), + prefix("/api/gnet/"), // Already gzipped by grafana.com. prefix("/metrics"), prefix("/api/live/ws"), // WebSocket does not support gzip compression. prefix("/api/live/push"), // WebSocket does not support gzip compression.