質問編集履歴
2
ソースコードと試したことを追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -17,4 +17,45 @@
|
|
17
17
|
開発環境: EC2
|
18
18
|
本番環境: ALB配下のEC2
|
19
19
|
|
20
|
-
どちらも自分のIPからはアクセス可能です。
|
20
|
+
どちらも自分のIPからはアクセス可能です。
|
21
|
+
|
22
|
+
〜〜〜
|
23
|
+
|
24
|
+
## 追記
|
25
|
+
CheckForMaintenanceModeをオーバーライドし、HTTP_X_FORWARDED_FORを読むようにしました。
|
26
|
+
※本番では未確認
|
27
|
+
|
28
|
+
```
|
29
|
+
/**
|
30
|
+
* Handle an incoming request.
|
31
|
+
*
|
32
|
+
* @param \Illuminate\Http\Request $request
|
33
|
+
* @param \Closure $next
|
34
|
+
* @return mixed
|
35
|
+
*
|
36
|
+
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
|
37
|
+
*/
|
38
|
+
public function handle($request, Closure $next)
|
39
|
+
{
|
40
|
+
if ($this->app->isDownForMaintenance()) {
|
41
|
+
$data = json_decode(file_get_contents($this->app->storagePath().'/framework/down'), true);
|
42
|
+
|
43
|
+
// ロードバランサー対応
|
44
|
+
if (isset($data['allowed']) && IpUtils::checkIp($request->server->get('HTTP_X_FORWARDED_FOR'), (array) $data['allowed'])) {
|
45
|
+
return $next($request);
|
46
|
+
}
|
47
|
+
|
48
|
+
if (isset($data['allowed']) && IpUtils::checkIp($request->ip(), (array) $data['allowed'])) {
|
49
|
+
return $next($request);
|
50
|
+
}
|
51
|
+
|
52
|
+
if ($this->inExceptArray($request)) {
|
53
|
+
return $next($request);
|
54
|
+
}
|
55
|
+
|
56
|
+
throw new MaintenanceModeException($data['time'], $data['retry'], $data['message']);
|
57
|
+
}
|
58
|
+
|
59
|
+
return $next($request);
|
60
|
+
}
|
61
|
+
```
|
1
環境追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -9,4 +9,12 @@
|
|
9
9
|
|
10
10
|
## やったこと
|
11
11
|
|
12
|
-
`$ artisan down --allow=xxx.xxx.xxx.xxx`(自分のIP)
|
12
|
+
`$ artisan down --allow=xxx.xxx.xxx.xxx`(自分のIP)
|
13
|
+
|
14
|
+
## 環境
|
15
|
+
AWS
|
16
|
+
|
17
|
+
開発環境: EC2
|
18
|
+
本番環境: ALB配下のEC2
|
19
|
+
|
20
|
+
どちらも自分のIPからはアクセス可能です。
|