简体   繁体   English

如何在 nodejs linux 上启用 gzip 压缩 react Azure Web App with nginx

[英]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.

相关问题 为运行在 Azure 上的节点应用程序启用 gzip - Enable gzip for node app running on Azure 如何将 Azure AppSettings 传递给运行在 Linux AppService 上的 NodeJS App - How to pass Azure AppSettings to NodeJS App running on Linux AppService 如何在Azure Web App Service Linux环境下安装自己的Python package? - How can I install my own Python package in Azure Web App Service Linux environment? 如何将 gzip 或 bzip 文件放入 GCP 上的 Linux VM 中。我在公司 Windows 笔记本电脑上 - How do I get gzip or bzip files into a Linux VM on GCP.. I am on a company Windows laptop React js压缩gzip/brotli推荐大小 - React js compression gzip/brotli recommended size 如何在 GCE 中为具有多个子域的多个 web 应用程序设置 nginx - How do I setup nginx for multiple web app with multiple subdomains in GCE 如何在 Linux Azure Web App 上安装和配置 Oracle Instant Client - How to install and configure Oracle Instant Client on a Linux Azure Web App 如何创建使用 azure tts 将音频发送到 web 应用程序的 expressjs 端点? - How do I create an expressjs endpoint that uses azure tts to send audio to a web app? 在 Linux 上启用端口 443 Nginx - Enable port 443 on Linux Nginx 修改nginx.conf为Azure App Linux服务 - Modifying nginx.conf for Azure App Linux Service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM