質問編集履歴
3
進展分追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,6 +16,30 @@
|
|
16
16
|
|
17
17
|
|
18
18
|
|
19
|
+
追記
|
20
|
+
|
21
|
+
rails s -d で起動すると、
|
22
|
+
|
23
|
+
```
|
24
|
+
|
25
|
+
puma 5.3.2 (tcp://localhost:3000)
|
26
|
+
|
27
|
+
```
|
28
|
+
|
29
|
+
rails sで起動して、別ターミナルでpsを確認すると
|
30
|
+
|
31
|
+
```
|
32
|
+
|
33
|
+
puma 5.3.2 (unix:///opt/rails-app-name/tmp/sockets/puma.sock)
|
34
|
+
|
35
|
+
```
|
36
|
+
|
37
|
+
という結果になった。
|
38
|
+
|
39
|
+
-dオプションをつけるか付けないかの違いでなぜ受付ポートに差が出てしまうのか、不明です。。
|
40
|
+
|
41
|
+
|
42
|
+
|
19
43
|
### 該当のソースコード
|
20
44
|
|
21
45
|
#### Nginx系
|
2
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -138,7 +138,7 @@
|
|
138
138
|
|
139
139
|
listen 443 ssl http2;
|
140
140
|
|
141
|
-
server_name
|
141
|
+
server_name XXX.com;
|
142
142
|
|
143
143
|
|
144
144
|
|
@@ -164,9 +164,9 @@
|
|
164
164
|
|
165
165
|
|
166
166
|
|
167
|
-
ssl_certificate /etc/letsencrypt/live/
|
167
|
+
ssl_certificate /etc/letsencrypt/live/XXX.com/fullchain.pem;
|
168
|
-
|
168
|
+
|
169
|
-
ssl_certificate_key /etc/letsencrypt/live/
|
169
|
+
ssl_certificate_key /etc/letsencrypt/live/XXX.com/privkey.pem;
|
170
170
|
|
171
171
|
|
172
172
|
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
Nginxをリバースプロキシとして使用し、RailsのAPサーバであるPumaに連携したい。
|
5
|
+
Nginxをリバースプロキシとして使用し、RailsのAPサーバであるPumaにUNIXドメイン連携したい。
|
6
6
|
|
7
7
|
|
8
8
|
|
@@ -10,6 +10,10 @@
|
|
10
10
|
|
11
11
|
ブラウザからHTTPSアクセスしてもNginxのページまでしか届かない。
|
12
12
|
|
13
|
+
--> ps aux | grep puma でプロセスを確認したところ、http://localhost:3000と表示された
|
14
|
+
|
15
|
+
しかしrails sを実行するとListening on unix:///opt/sp-aws-educate/tmp/sockets/puma.sockと表示される。ここが一致すればおそらく解消されるはずだが、、どのようにすれば良いか分かりません。
|
16
|
+
|
13
17
|
|
14
18
|
|
15
19
|
### 該当のソースコード
|
@@ -178,7 +182,157 @@
|
|
178
182
|
|
179
183
|
```
|
180
184
|
|
181
|
-
|
185
|
+
/etc/nginx/conf.d/rails-app-name.conf
|
186
|
+
|
187
|
+
```
|
188
|
+
|
189
|
+
upstream rails-app-name {
|
190
|
+
|
191
|
+
server unix:///opt/rails-app-name/tmp/sockets/puma.sock;
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
server {
|
196
|
+
|
197
|
+
listen 80;
|
198
|
+
|
199
|
+
server_name XXX.com;
|
200
|
+
|
201
|
+
root /opt/rails-app-name/public;
|
202
|
+
|
203
|
+
try_files $uri/index.html $uri.html $uri @rails-app-name;
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
location @rails-app-name {
|
208
|
+
|
209
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
210
|
+
|
211
|
+
proxy_set_header Host $http_host;
|
212
|
+
|
213
|
+
proxy_redirect off;
|
214
|
+
|
215
|
+
proxy_pass http://rails-app-name;
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
error_page 500 502 503 504 /500.html;
|
220
|
+
|
221
|
+
location = /500.html {
|
222
|
+
|
223
|
+
root /opt/rails-app-name/public;
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
}
|
228
|
+
|
229
|
+
```
|
230
|
+
|
231
|
+
/var/log/nginx/error.log
|
232
|
+
|
233
|
+
```
|
234
|
+
|
235
|
+
[error] connect() to unix:///opt/rails-app-name/tmp/sockets/puma.sock failed (111: Connection refused) while connecting to upstream, client: XXX.XXX.XXX.XXX, server: XXX.com, request: "GET /wp-admin/install.php?step=1 HTTP/1.1", upstream: "http://unix:///opt/rails-app-name/tmp/sockets/puma.sock:/wp-admin/install.php?step=1", host: "XXX.com"
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
```
|
240
|
+
|
241
|
+
/opt/rails-app-name/config/puma.rb
|
242
|
+
|
243
|
+
```
|
244
|
+
|
245
|
+
# Puma can serve each request in a thread from an internal thread pool.
|
246
|
+
|
247
|
+
# The `threads` method setting takes two numbers: a minimum and maximum.
|
248
|
+
|
249
|
+
# Any libraries that use thread pools should be configured to match
|
250
|
+
|
251
|
+
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
252
|
+
|
253
|
+
# and maximum; this matches the default thread size of Active Record.
|
254
|
+
|
255
|
+
#
|
256
|
+
|
257
|
+
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
|
258
|
+
|
259
|
+
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
|
260
|
+
|
261
|
+
threads min_threads_count, max_threads_count
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
# Specifies the `worker_timeout` threshold that Puma will use to wait before
|
266
|
+
|
267
|
+
# terminating a worker in development environments.
|
268
|
+
|
269
|
+
#
|
270
|
+
|
271
|
+
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
276
|
+
|
277
|
+
#
|
278
|
+
|
279
|
+
#port ENV.fetch("PORT") { 3000 }
|
280
|
+
|
281
|
+
bind "unix:///opt/rails-app-name/tmp/sockets/puma.sock"
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
# Specifies the `environment` that Puma will run in.
|
286
|
+
|
287
|
+
#
|
288
|
+
|
289
|
+
environment ENV.fetch("RAILS_ENV") { "development" }
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
# Specifies the `pidfile` that Puma will use.
|
294
|
+
|
295
|
+
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
# Specifies the number of `workers` to boot in clustered mode.
|
300
|
+
|
301
|
+
# Workers are forked web server processes. If using threads and workers together
|
302
|
+
|
303
|
+
# the concurrency of the application would be max `threads` * `workers`.
|
304
|
+
|
305
|
+
# Workers do not work on JRuby or Windows (both of which do not support
|
306
|
+
|
307
|
+
# processes).
|
308
|
+
|
309
|
+
#
|
310
|
+
|
311
|
+
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
# Use the `preload_app!` method when specifying a `workers` number.
|
316
|
+
|
317
|
+
# This directive tells Puma to first boot the application and load code
|
318
|
+
|
319
|
+
# before forking the application. This takes advantage of Copy On Write
|
320
|
+
|
321
|
+
# process behavior so workers use less memory.
|
322
|
+
|
323
|
+
#
|
324
|
+
|
325
|
+
# preload_app!
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
# Allow puma to be restarted by `rails restart` command.
|
330
|
+
|
331
|
+
plugin :tmp_restart
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
```
|
182
336
|
|
183
337
|
`
|
184
338
|
|
@@ -186,9 +340,17 @@
|
|
186
340
|
|
187
341
|
### 試したこと
|
188
342
|
|
189
|
-
|
190
|
-
|
191
|
-
|
343
|
+
* nginxで(111: Connection refused)が出て、アクセスできないです。
|
344
|
+
|
345
|
+
https://teratail.com/questions/308033
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
--> ps aux | grep puma でプロセスを確認したところ、http://localhost:3000と表示された
|
350
|
+
|
351
|
+
しかしrails sを実行するとListening on unix:///opt/sp-aws-educate/tmp/sockets/puma.sockと表示される。ここが一致すればおそらく解消されるはずだが、、どのようにすれば良いか分かりません。
|
352
|
+
|
353
|
+
|
192
354
|
|
193
355
|
|
194
356
|
|
@@ -196,4 +358,10 @@
|
|
196
358
|
|
197
359
|
|
198
360
|
|
199
|
-
|
361
|
+
* cent os 8.4.2105
|
362
|
+
|
363
|
+
* ruby 2.6.3p62
|
364
|
+
|
365
|
+
* Rails 6.1.4
|
366
|
+
|
367
|
+
* Puma 5.3.2 (ruby 2.6.3-p62) ("Sweetnighter")
|