0
我試圖安裝在nginx的一個作出反應的應用程序,但是從一個子目錄提供靜態文件時,我面臨的一個問題Nginx的404(反應的應用程序)
我的文件樹是這樣的:
/var/www/
antoinedeveyrac.io/
...
react/
...
build/
index.html
static/
js
*.js
css
*.css
我的conf文件是:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
include snippets/ssl-antoinedeveyrac.io.conf;
include snippets/ssl-params.conf;
root /var/www/antoinedeveyrac.io/html;
index index.html index.htm index.nginx-debian.html;
server_name antoinedeveyrac.io www.antoinedeveyrac.io;
location/{
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location ~ /.well-known {
allow all;
}
location /react {
alias /var/www/react/build;
try_files $uri $uri/ =404;
autoindex off;
index index.html;
}
}
所以,當我打https://antoinedeveyrac.io/react,我有那些404錯誤,這意味着nginx的不明白,我想從服務文件而不是https://antoinedeveyrac.io/static/...
如何修復我的配置文件以匹配子目錄中的靜態文件?非常感謝:)