33
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Nginxのtry_filesディレクティブ設定例

Posted at

Nginxの設定にて、静的なファイルと動的なURLを振り分けたいことがあります。try_filesを利用すれば、指定した順番で確認と転送を実施してくれます。

参考
Module ngx_http_core_module

以下の順番で確認するよう設定します
1. URLのパスにファイルがあるか
2. 1がなかった場合、URLのパスにディレクトリがあるか
3. 12がなかった場合、指定したロケーションに行く

location / {
    root /home/user/app/public/;
    try_files $uri $uri/ @dinamic;
}

location @dinamic {
    proxy_pass http://upstream;
}
33
18
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
33
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?