質問編集履歴

2

ソースコードと試したことを追加

2019/06/14 12:02

投稿

poteto4401
poteto4401

スコア57

test CHANGED
File without changes
test CHANGED
@@ -37,3 +37,85 @@
37
37
 
38
38
 
39
39
  どちらも自分のIPからはアクセス可能です。
40
+
41
+
42
+
43
+ 〜〜〜
44
+
45
+
46
+
47
+ ## 追記
48
+
49
+ CheckForMaintenanceModeをオーバーライドし、HTTP_X_FORWARDED_FORを読むようにしました。
50
+
51
+ ※本番では未確認
52
+
53
+
54
+
55
+ ```
56
+
57
+ /**
58
+
59
+ * Handle an incoming request.
60
+
61
+ *
62
+
63
+ * @param \Illuminate\Http\Request $request
64
+
65
+ * @param \Closure $next
66
+
67
+ * @return mixed
68
+
69
+ *
70
+
71
+ * @throws \Symfony\Component\HttpKernel\Exception\HttpException
72
+
73
+ */
74
+
75
+ public function handle($request, Closure $next)
76
+
77
+ {
78
+
79
+ if ($this->app->isDownForMaintenance()) {
80
+
81
+ $data = json_decode(file_get_contents($this->app->storagePath().'/framework/down'), true);
82
+
83
+
84
+
85
+ // ロードバランサー対応
86
+
87
+ if (isset($data['allowed']) && IpUtils::checkIp($request->server->get('HTTP_X_FORWARDED_FOR'), (array) $data['allowed'])) {
88
+
89
+ return $next($request);
90
+
91
+ }
92
+
93
+
94
+
95
+ if (isset($data['allowed']) && IpUtils::checkIp($request->ip(), (array) $data['allowed'])) {
96
+
97
+ return $next($request);
98
+
99
+ }
100
+
101
+
102
+
103
+ if ($this->inExceptArray($request)) {
104
+
105
+ return $next($request);
106
+
107
+ }
108
+
109
+
110
+
111
+ throw new MaintenanceModeException($data['time'], $data['retry'], $data['message']);
112
+
113
+ }
114
+
115
+
116
+
117
+ return $next($request);
118
+
119
+ }
120
+
121
+ ```

1

環境追加

2019/06/14 12:02

投稿

poteto4401
poteto4401

スコア57

test CHANGED
File without changes
test CHANGED
@@ -21,3 +21,19 @@
21
21
 
22
22
 
23
23
  `$ artisan down --allow=xxx.xxx.xxx.xxx`(自分のIP)
24
+
25
+
26
+
27
+ ## 環境
28
+
29
+ AWS
30
+
31
+
32
+
33
+ 開発環境: EC2
34
+
35
+ 本番環境: ALB配下のEC2
36
+
37
+
38
+
39
+ どちらも自分のIPからはアクセス可能です。