[英]nginx: how to serve file from a subfolder of root?
我的本地開發環境在 nginx 上按原樣配置
server {
listen 80;
server_name project.local;
root /var/www/project.local/public;
charset utf-8;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
# Questi due parametri sono fondamentali
# per le app Laravel
# => https://serverfault.com/a/927619/178670
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
問題僅在於根目錄內的文件夾 /fonts,位於 /var/www/project.local/fonts
注意:這不是我的代碼,我繼承了它... :( 注意 2:這是一個舊的 laravel 5.4 項目
實際上,當網站查找 fonts/some.file 時,我得到了 404,但該文件已經在這里了。
我應該在 nginx conf 中更改什么以允許從 /var/www/project.local/fonts 提供 /fonts/some.file ?
為什么實際上不起作用?
固定添加
location /fonts {
root /var/www/prod.revisions;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.