[英]How do I enable gzip compression on a nodejs linux react Azure Web App with nginx
Code solutions that add Content-Encoding: gzip to Response Headers seem to work locally but not on the Azure slot.将 Content-Encoding: gzip 添加到 Response Headers 的代码解决方案似乎在本地有效,但在 Azure 插槽上无效。
I have SSHed onto the container and the nginx.config gzip setting is commented out, It is set by default for Windows slots.我已经通过 SSH 连接到容器上,nginx.config gzip 设置被注释掉了,它默认设置为 Windows 插槽。 but commented out by MS for Linux ones.但被 MS 注释掉了 Linux 个。
Normally I would just edit the nginx.config - but how do I make the changes persistent over a slot restart?通常我只会编辑 nginx.config - 但我如何使更改在插槽重新启动后保持不变? Changes done to the nginx.config via SSH on the slot instance itself are NOT persisted on slot restart通过插槽实例本身的 SSH 对 nginx.config 所做的更改不会在插槽重启时保留
Modifying nginx.conf for Azure App Linux Service suggests it CANNOT be done. 为 Azure 应用程序 Linux 服务修改 nginx.conf表明无法完成。
I can't see how to do that with the Azure Web App setting - there seem no settings on the slot in the Azure UI.我看不到如何使用 Azure Web 应用程序设置来做到这一点 - Azure UI 中的插槽似乎没有设置。
Does anyone know how to do this?有谁知道如何做到这一点? Or that it definitely CANNOT be done by any means?或者它绝对不能以任何方式完成?
NOTE: This is NOT an nginx config question but an Azure Linux slot specific one!注意:这不是 nginx 配置问题,而是 Azure Linux 插槽特定问题!
Here is a Nginx server block that enables gzip for you:这是一个 Nginx 为您启用 gzip 的服务器块:
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 0;
gzip_types text/plain application/javascript text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype;
Gave up on this line of thought and since it was a static website, put it on a CDN, problem solved.放弃这个思路,既然是static网站,放到CDN上,问题就解决了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.