質問編集履歴

1

質問内容の修正

2018/05/29 13:52

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- nginxの分岐処理について
1
+ nginxの処理について
test CHANGED
@@ -4,43 +4,25 @@
4
4
 
5
5
 
6
6
 
7
+
8
+
7
9
  ```
8
10
 
9
- if ($request_uri = /a) {
11
+ location /if-try-files {
10
12
 
11
- set $test A;
13
+ try_files /file @fallback;
12
-
13
- }
14
14
 
15
15
 
16
16
 
17
- if ($request_uri = /b) {
18
-
19
- set $test B;
17
+ set $true 1;
20
-
21
- }
22
18
 
23
19
 
24
20
 
25
- if ($request_uri = /c) {
21
+ if ($true) {
26
22
 
27
- set $test A;
23
+ # nothing
28
24
 
29
- }
25
+ }
30
-
31
-
32
-
33
- if ($test == A){
34
-
35
- include A用のlocationが定義されたファイルでproxy_pass振り分け
36
-
37
- }
38
-
39
-
40
-
41
- if ($test == B) {
42
-
43
- include B用のlocationが定義されたファイルでproxy_pass振り分け
44
26
 
45
27
  }
46
28
 
@@ -48,8 +30,4 @@
48
30
 
49
31
 
50
32
 
51
- 上記の場合、if文中にincludeを指定するは文法的エラーになります。
33
+ 上記のtry_files 使いかた
52
-
53
- また、If Is Evilともいわれているので上記のようなコードを別の手段で書きたいのですが、代替手段がわからずお力をお借りしたく存じ上げます。
54
-
55
- https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/