1.我的环境是Redhat 7,Django 2.2,nginx版本:nginx/1.15.12。我有两个静态位置,我需要在两个时间都得到服务。同一服务器上的第一个位置和第二个位置是已安装的网络驱动器,用于存储图像和所有其他 pdf。
有两个问题。1. 如何为两个静态位置提供服务。这两个位置是 a)/www/AutomationServices/static b)/storage/Investigator_Validator。在 nginx conf 我试过
location /static/ {
autoindex on;
root /www/AutomationServices/static;
try_files $uri $uri/ @secondStatic;
}
location /storage/ {
root /storage/Investigator_Validator;
}
location @secondStatic{
root /storage/Investigator_Validator;
}
我在 /storage/Investigator_Validator 下有多个文件夹。在每个子文件夹中都有根据其分类分组的 pdf、图像和文本文件。当我试图为他们服务时,它不起作用。但是当我尝试 python manage.py collectstatic 时,/storage/Investigator_Validator 中的文件夹和文件被复制到这个文件夹/www/AutomationServices/static 中。它当时有效,但 /storage/Investigator_Validator 中的文件会动态变化,因此每次创建这些图像时运行 python manage.py collectstatic 并不好。
需要使用 nginx 网络服务器提供两个静态位置。如何使用 nginx 在文件夹中搜索 js、css、images 文件的子文件夹。