質問編集履歴
3
docker-compose.ymlの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,6 +6,100 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
+
docker-compose.yml
|
10
|
+
|
11
|
+
```ここに言語を入力
|
12
|
+
|
13
|
+
version : '3'
|
14
|
+
|
15
|
+
services:
|
16
|
+
|
17
|
+
db:
|
18
|
+
|
19
|
+
image: mysql:5.7
|
20
|
+
|
21
|
+
environment:
|
22
|
+
|
23
|
+
MYSQL_ROOT_PASSWORD: password
|
24
|
+
|
25
|
+
MYSQL_DATABASE: root
|
26
|
+
|
27
|
+
volumes:
|
28
|
+
|
29
|
+
- ./docker/db/data:/var/lib/mysql
|
30
|
+
|
31
|
+
ports:
|
32
|
+
|
33
|
+
- "3306:3306"
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
web:
|
38
|
+
|
39
|
+
tty: true
|
40
|
+
|
41
|
+
stdin_open: true
|
42
|
+
|
43
|
+
build: .
|
44
|
+
|
45
|
+
command: /bin/sh -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
|
46
|
+
|
47
|
+
volumes:
|
48
|
+
|
49
|
+
- .:/my_song
|
50
|
+
|
51
|
+
ports:
|
52
|
+
|
53
|
+
- "3000:3000"
|
54
|
+
|
55
|
+
links:
|
56
|
+
|
57
|
+
- db
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
server:
|
62
|
+
|
63
|
+
build:
|
64
|
+
|
65
|
+
context: containers/nginx
|
66
|
+
|
67
|
+
volumes:
|
68
|
+
|
69
|
+
- ./nginx/log:/var/log/nginx
|
70
|
+
|
71
|
+
- public-data:/my_song/public
|
72
|
+
|
73
|
+
ports:
|
74
|
+
|
75
|
+
- 80:80
|
76
|
+
|
77
|
+
depends_on:
|
78
|
+
|
79
|
+
- web
|
80
|
+
|
81
|
+
volumes:
|
82
|
+
|
83
|
+
public-data:
|
84
|
+
|
85
|
+
tmp-data:
|
86
|
+
|
87
|
+
log-data:
|
88
|
+
|
89
|
+
db-data:
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
```
|
102
|
+
|
9
103
|
puma.rb
|
10
104
|
|
11
105
|
```ここに言語を入力
|
2
puma.rb
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,7 +6,33 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
+
puma.rb
|
9
10
|
|
11
|
+
```ここに言語を入力
|
12
|
+
|
13
|
+
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
|
14
|
+
|
15
|
+
threads threads_count, threads_count
|
16
|
+
|
17
|
+
port ENV.fetch("PORT") { 3000 }
|
18
|
+
|
19
|
+
environment ENV.fetch("RAILS_ENV") { "development" }
|
20
|
+
|
21
|
+
plugin :tmp_restart
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
app_root = File.expand_path("../..", __FILE__)
|
26
|
+
|
27
|
+
bind "unix://#{app_root}/tmp/sockets/puma.sock"
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
stdout_redirect "#{app_root}/log/puma.stdout.log", "#{app_root}/log/puma.stderr.log", true
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
```
|
10
36
|
|
11
37
|
containers/nginx.conf
|
12
38
|
|
1
nginx.confの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -3,6 +3,82 @@
|
|
3
3
|
nginexのエラーログを見ると下記のようになってしました。
|
4
4
|
|
5
5
|
解決方法を教えていただけないでしょうか。
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
containers/nginx.conf
|
12
|
+
|
13
|
+
```ここに言語を入力
|
14
|
+
|
15
|
+
# プロキシ先の指定
|
16
|
+
|
17
|
+
# Nginxが受け取ったリクエストをバックエンドのpumaに送信
|
18
|
+
|
19
|
+
upstream my_song {
|
20
|
+
|
21
|
+
# ソケット通信したいのでpuma.sockを指定
|
22
|
+
|
23
|
+
server unix:///my_song/tmp/sockets/puma.sock;
|
24
|
+
|
25
|
+
}
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
server {
|
30
|
+
|
31
|
+
listen 80;
|
32
|
+
|
33
|
+
# ドメインもしくはIPを指定
|
34
|
+
|
35
|
+
server_name example.com [or 54.65.94.96 [or localhost]];
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
access_log /var/log/nginx/access.log;
|
40
|
+
|
41
|
+
error_log /var/log/nginx/error.log;
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
# ドキュメントルートの指定
|
46
|
+
|
47
|
+
root /my_song/public;
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
client_max_body_size 100m;
|
52
|
+
|
53
|
+
error_page 404 /404.html;
|
54
|
+
|
55
|
+
error_page 505 502 503 504 /500.html;
|
56
|
+
|
57
|
+
try_files $uri/index.html $uri @my_song;
|
58
|
+
|
59
|
+
keepalive_timeout 5;
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
# リバースプロキシ関連の設定
|
64
|
+
|
65
|
+
location @my_song {
|
66
|
+
|
67
|
+
proxy_set_header X-Real-IP $remote_addr;
|
68
|
+
|
69
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
70
|
+
|
71
|
+
proxy_set_header Host $http_host;
|
72
|
+
|
73
|
+
proxy_pass http://my_song;
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
```
|
6
82
|
|
7
83
|
```ここに言語を入力
|
8
84
|
|