Http Google云负载均衡器未返回内容编码:gzip
我使用的是位于nginx后端服务前面的googlecloud负载平衡器(用googlecloud术语) 当我直接访问nginx服务器时,我可以看到“Content Encoding:gzip”标题(左侧)。 但是来自负载平衡器的响应不包含此标题(右侧)。 我已经在我的nginx配置文件中启用了gzip_代理:Http Google云负载均衡器未返回内容编码:gzip,http,nginx,google-cloud-platform,load-balancing,Http,Nginx,Google Cloud Platform,Load Balancing,我使用的是位于nginx后端服务前面的googlecloud负载平衡器(用googlecloud术语) 当我直接访问nginx服务器时,我可以看到“Content Encoding:gzip”标题(左侧)。 但是来自负载平衡器的响应不包含此标题(右侧)。 我已经在我的nginx配置文件中启用了gzip_代理: server { listen 80; gzip on; gzip_vary on; gzip_proxied any; // <------ H
server {
listen 80;
gzip on;
gzip_vary on;
gzip_proxied any; // <------ Here
gzip_types text/plain text/css text/js text/xml text/javascript application/javascript application/x-javascript application/json application/xml application/rss+xml image/svg+xml;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
root /usr/share/nginx/html;
index index.html index.htm;
location / {
gzip_static on;
if ($http_x_forwarded_proto = "http") {
return 301 https://$host$request_uri;
}
try_files $uri $uri/ /index.html;
}
}
服务器{
听80;
gzip on;
gzip_随时间而变化;
gzip_代理了任何;//云负载平衡器本身不压缩或解压缩响应。它们为使用压缩的后端实例生成的响应提供服务。您需要启用
为了在负载平衡器的响应中包含此标头,您可能需要在nginx配置文件中设置接受编码标头,并修改用户代理以包含字符串代理,如中所述
例如:
接受编码:gzip
用户代理:我的程序(gzip)始终使用gzip\u static
,甚至可能在服务器中,而不是位置中。仍然相同。