node.js - Nginx 配置以在根文件夹中提供动态文件
问题描述
我有一个具有以下结构的 mern 堆栈应用程序
.app/
--client folder
-server.js
-storage folder
该应用程序在本地运行良好,但当我部署到 amazone (ec2) 并配置 pm2 和 nginx 时,一切正常,但保存在我的存储文件夹中的图像的唯一问题似乎没有提供。构建文件夹中的静态图像正常显示,但是当用户上传他的个人资料图像时,例如保存在存储中的图像,图像被保存但不显示。
我的 nginx 配置很常见:
root /path/tp/build;
location / {
try_files $uri /index.html;
}
location /api/ {
proxy_pass http://localhost:8080;
//other default configs;
}
我试图使用 config 使其工作,但没有成功。我还在 nginx 配置中为存储文件夹添加了一个位置
location /storage/ {
root /path/to/storage/;
try_files $uri /;
}
我会很感激任何帮助,谢谢。
解决方案
推荐阅读
- r - 使用 R 中的 xml2 包提取 xml 节点时出现问题
- asp.net-core-mvc - 获取 Asp.Net Core 2 MVC ReleaseVersion
- python-2.7 - 如何防止 virtualenv 替换软件包?
- postgresql - WARNING,在不安全模式下运行,JWT secret 是默认值 Listening on port 3000
- c# - 未出现在 ComboBox 列表 C# 中的项目
- html - 如何控制 ngFor 末尾的特殊字符
- reactjs - 使用 clearTimeout 和 setTimeout 的正确方法?
- javascript - 我需要一个同时工作的倒数计时器
- git - 将 Git 索引复制到临时文件夹中
- html - 什么都没有时CSS网格填充空间