に書き換えようとし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はよりパフォーマンスが高く、慣用的だと思います。