【发布时间】:2019-01-26 15:57:05
【问题描述】:
我正在使用位于 nginx 后端服务前面的谷歌云负载均衡器(在谷歌云术语中)。
当我直接访问 nginx 服务器时,我可以看到 'Content-Encoding: gzip' 标头(左侧)。
但来自负载均衡器的响应不包含此标头(右侧)。
我已经在我的 nginx 配置文件中启用了 gzip_proxied:
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;
}
}
相关链接失效:
Google Cloud HTTP Balancer and gzip
有什么想法吗?
【问题讨论】:
-
使用
gzip_static always,甚至可能在server而不是location中。 -
还是一样。
标签: http nginx google-cloud-platform load-balancing