に書き換えようとしGET /
てい/srv/app/static/index.html
ます。私はこれらのいくつかのディレクティブに近いです:
root /srv/app/static;
location /static {
alias /srv/app/static;
}
location = / {
alias /srv/app/static/index.html;
}
だから、私GET /static
が nginx でファイルを提供する/srv/app/static/index.html
と、私は満足しています。
しかし、私が するとGET /
、nginx は 404 を返します。ログを確認すると、ファイルにアクセスしようとしていることがわかります/srv/app/static/index.htmlindex.html
(sic)。index.html
で指定されたパスに余分なものを追加するのはなぜalias
ですか?
そのディレクティブを
location = / {
index index.html;
alias /srv/app/static/;
}
エラー ログには、アクセスしようとしていることが示されています(つまり、最後の文字が から/srv/app/stati
削除されます。ここで何が起こっているのでしょうか?c
/srv/app/static
編集:
rewrite
次のように使用して、必要な動作を取得できます。
location = / {
rewrite (.*) /static/index.html;
}
しかし、私alias
はよりパフォーマンスが高く、慣用的だと思います。