Last active
April 13, 2024 03:00
Revisions
-
kenjiskywalker revised this gist
Jan 22, 2013 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -43,13 +43,13 @@ try_files $uri $uri/ /hoge.html; でexample.com/hoge でアクセスして `$uri = "hoge"` ./hoge というファイルが存在しなければ `$url/ = "hoge/"` ./hoge/ というディレクトリを探しに行く `/hoge.html` ./hoge.html というファイルもなければ ステータスコードは ***500*** になる(もうちょっと検証が必要かも)。 @@ -58,7 +58,7 @@ try_files $uri $uri/ /hoge.html /hogehoge.html; ``` この場合、上の3つを探して見つからない場合は `/hogehoge.html` ./hogehoge.html を探しにいく。 条件はいくらでも増やせる -
kenjiskywalker revised this gist
Jan 22, 2013 . 1 changed file with 0 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -44,15 +44,12 @@ try_files $uri $uri/ /hoge.html; でexample.com/hoge でアクセスして `$uri = "hoge"` ./hoge というファイルが存在しなければ `$url/ = "hoge/"` ./hoge/ というディレクトリを探しに行く `/hoge.html` ./hoge.html というファイルもなければ ステータスコードは ***500*** になる(もうちょっと検証が必要かも)。 @@ -62,7 +59,6 @@ try_files $uri $uri/ /hoge.html /hogehoge.html; この場合、上の3つを探して見つからない場合は `/hogehoge.html` ./hogehoge.html を探しにいく。 条件はいくらでも増やせる -
kenjiskywalker revised this gist
Jan 22, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -54,7 +54,7 @@ try_files $uri $uri/ /hoge.html; `/hoge.html` ./hoge.html というファイルもなければ ステータスコードは ***500*** になる(もうちょっと検証が必要かも)。 ``` try_files $uri $uri/ /hoge.html /hogehoge.html; -
kenjiskywalker revised this gist
Jan 22, 2013 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -78,12 +78,12 @@ try_files $uri $uri/ /hoge.html =404; ``` 最後の条件にステータスコードを渡せば 条件にひっかからなければテータスコードが返る。 上記の場合は ***404*** が返る。 ``` try_files $uri $uri/ /hoge.html =404; ``` *./hoge.html* というファイルが存在した場合は 後ろのステータスコードは無視されステータスコードは ***200*** が返る。 -
kenjiskywalker revised this gist
Jan 22, 2013 . 1 changed file with 5 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ ## nginx config `nginx.conf` @@ -54,7 +53,7 @@ try_files $uri $uri/ /hoge.html; `/hoge.html` ./hoge.html というファイルもなければ status code は ***500*** になる(もうちょっと検証が必要かも)。 ``` @@ -64,28 +63,27 @@ try_files $uri $uri/ /hoge.html /hogehoge.html; `/hogehoge.html` ./hogehoge.html を探しにいく。 条件はいくらでも増やせる ### 条件の複数指定 ``` try_files $uri $uri/ /ho.html /hog.html /hoge.html /hogee.html; ``` これもいけた。 ### 条件にステータスコードを渡す ``` try_files $uri $uri/ /hoge.html =404; ``` 最後の条件にステータスコードを渡せば 条件にひっかからなければテータスコードが返る。 ``` try_files $uri $uri/ /hoge.html =404; ``` *./hoge.html* というファイルが存在した場合は 後ろのステータスコードは無視されステータスコードは***200***が返る。 -
kenjiskywalker revised this gist
Jan 22, 2013 . 1 changed file with 61 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ ## nginx config `nginx.conf` @@ -11,6 +12,7 @@ server { error_log /var/log/nginx/error_log error; try_files $uri $uri/ /hoge.html; } ``` @@ -28,4 +30,62 @@ $ ```bash $ tail access_log "GET /hogehogehogeeee HTTP/1.1" 200 10 "-" "curl ~ ``` ## 例えば [http://wiki.nginx.org/HttpCoreModule#try_files](http://wiki.nginx.org/HttpCoreModule#try_files) オフィシャルを参考に ``` try_files $uri $uri/ /hoge.html; ``` でexample.com/hoge でアクセスして `$uri = "hoge"` ./hoge というファイルが存在しなければ `$url/ = "hoge/"` ./hoge/ というディレクトリを探しに行く `/hoge.html` ./hoge.html というファイルもなければ status code は ***500*** になる(もうちょっと検証が必要かも)。 ``` try_files $uri $uri/ /hoge.html /hogehoge.html; ``` この場合、上の3つを探して見つからない場合は `/hogehoge.html` ./hogehoge.html を探しにいく。 条件はいくらでも増やせる ### 条件の複数指定 ``` try_files $uri $uri/ /ho.html /hog.html /hoge.html /hogee.html; ``` これもいけた。 ### 条件にステータスコードを渡す ``` try_files $uri $uri/ /hoge.html =404; ``` 最後の条件にステータスコードを渡せば 条件にひっかからなければテータスコードが返る。 ``` try_files $uri $uri/ /hoge.html =404; ``` *./hoge.html* というファイルが存在した場合は 後ろのステータスコードは無視されステータスコードは*200*が返る。 -
kenjiskywalker created this gist
Jan 22, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ ## nginx config `nginx.conf` ``` server { listen 80; server_name example.com; root /var/www/html/; index index.html; access_log /var/log/nginx/access_log hogehoge; error_log /var/log/nginx/error_log error; try_files $uri $uri/ /hoge.html; } ``` ## command line ``` $ cat hoge.html hoge dayo $ $ curl http://example.com/hogehogehogeeee hoge dayo $ ``` ## access log ```bash $ tail access_log "GET /hogehogehogeeee HTTP/1.1" 200 10 "-" "curl ~ ```