nginx - 从 NGINX Web 服务器加载 React 静态文件的问题
问题描述
NGINX Web 服务器大约需要 3 分钟来加载一个大约 3MB 的 React 静态文件。并且下载加载应用程序的性能很慢
我尝试在我的 React 文件上压缩静态文件
这是我在 NGINX 中的当前配置
upstream app1{
# Use ip_hash algo for session affinity
least_conn;
server 192.168.1.7:3000;
server 192.168.3.7:3000;
}
location /app1 {
# Force timeouts if the backend dies
#proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
# Set timeouts
proxy_connect_timeout 3600;
proxy_send_timeout 3600;
proxy_read_timeout 3600;
send_timeout 3600;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $http_host;
#proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass https://app1/;
proxy_buffering off;
}
location ~* ^/static {
proxy_pass https://app1$request_uri;
proxy_buffering off;
}
location ~ ^/build {
proxy_pass https://app1$request_uri;
}
我希望能够在 NGINX 服务器中提供静态内容,而无需从应用程序服务器获取。我还希望能够将文件压缩到最小大小,例如 10 KB。
解决方案
推荐阅读
- javascript - 自定义节点模块的依赖项未安装在根目录上
- python - 如何计算嵌套列表中的每次出现并将进度打印到python中的控制台?
- python - 如何按不同类型列出 gdb python 模块元素?
- c# - 尝试通过 c# 应用程序连接 IBM MQ 时遇到安全问题(原因代码:2063 和 2035)
- c# - 如何在 MVVM 灯光 MainViewmodel 中注册 IHttpClientFactory
- r - 将行“分箱”成范围(dplyr/R)
- c# - 如何解决 C# Unity 中的 NullReference 问题?
- ios - Xcode Flutter 插件'没有这样的模块'
- php - 隐藏在标题菜单后面的页面内容。我如何解决它?
- node.js - 我的 MERN 应用程序在部署到 heroku 时显示错误?