Google 云 HTTP 平衡器和 gzip

Google Cloud HTTP Balancer and gzip

当我使用 Google Cloud Network Load Balancer 时,我所有的 HTTP gzip 连接都保持原样,但是当使用 HTTP/S Load Balancer 时,最终用户不会获得 gzip 压缩的内容。

我在虚拟机上使用 nginx。使用此卷曲示例:

curl -H "Accept-Encoding: gzip" -H "Host: my.website.com" -I https://$IP_TO_TEST/login --insecure

直接连接到 VM 时得到 Content-Encoding: gzip,而当我连接到 HTTP 负载平衡器时得到 gzip。

我为此搜索了所有 Google 云文档,但他们没有提及是否支持从后端 gzip 内容。

HTTP/S 负载平衡器支持来自后端的 gzip 内容。您是否有可以分享的请求和响应示例 headers?你在 VM(nginx、Apache)上 运行 是什么?

Google 云 HTTP/S 负载平衡器支持来自后端的 gzip 内容。但是,通过负载均衡器代理的请求将具有 'Via: google 1.1' header added. The default nginx configuration does not trust proxies to be able to handle gzipped responses. The solution is to enable gzip_proxied.