質問編集履歴
3
nginx書き忘れ
test
CHANGED
File without changes
|
test
CHANGED
@@ -488,6 +488,8 @@
|
|
488
488
|
|
489
489
|
### 補足情報(FW/ツールのバージョンなど)
|
490
490
|
|
491
|
+
nginx
|
492
|
+
|
491
493
|
Rails 6.1.3.1
|
492
494
|
|
493
495
|
ruby 3.0.0p0
|
2
nginxのコード入れた
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,212 +56,402 @@
|
|
56
56
|
|
57
57
|
|
58
58
|
|
59
|
-
|
59
|
+
```ruby
|
60
|
+
|
61
|
+
ruby
|
62
|
+
|
63
|
+
log/production.log
|
64
|
+
|
65
|
+
[af1fe402-43d0-4797-900d-096e58574a44] ActionController::RoutingError (No route matches [GET] "/packs/media/slick/ajax-loader-c5cd7f53.gif"):
|
66
|
+
|
67
|
+
[af1fe402-43d0-4797-900d-096e58574a44]
|
68
|
+
|
69
|
+
F, [2021-07-20T13:53:30.078738 #14195] FATAL -- : [0eec3015-2980-4d50-88ea-dbdd38eee56e]
|
70
|
+
|
71
|
+
[0eec3015-2980-4d50-88ea-dbdd38eee56e] ActionController::RoutingError (No route matches [GET] "/packs/media/fonts/slick-d41f55a7.ttf"):
|
72
|
+
|
73
|
+
[0eec3015-2980-4d50-88ea-dbdd38eee56e]
|
74
|
+
|
75
|
+
F, [2021-07-20T13:53:36.578798 #14195] FATAL -- : [9170e9f1-6e53-4513-a842-5eb6b2a60fd6]
|
76
|
+
|
77
|
+
[9170e9f1-6e53-4513-a842-5eb6b2a60fd6] ActionController::RoutingError (No route matches [GET] "/packs/media/slick/ajax-loader-c5cd7f53.gif"):
|
78
|
+
|
79
|
+
[9170e9f1-6e53-4513-a842-5eb6b2a60fd6]
|
80
|
+
|
81
|
+
F, [2021-07-20T13:53:36.716955 #14195] FATAL -- : [45afdf57-8b00-43cf-93e7-b113b7a56154]
|
82
|
+
|
83
|
+
[45afdf57-8b00-43cf-93e7-b113b7a56154] ActionController::RoutingError (No route matches [GET] "/packs/media/fonts/slick-d41f55a7.ttf"):
|
84
|
+
|
85
|
+
[45afdf57-8b00-43cf-93e7-b113b7a56154]
|
86
|
+
|
87
|
+
F, [2021-07-20T13:54:02.049332 #14195] FATAL -- : [ce1c4b7b-19e1-46e3-b1a6-f73dac82ec46]
|
88
|
+
|
89
|
+
[ce1c4b7b-19e1-46e3-b1a6-f73dac82ec46] ActionController::RoutingError (No route matches [GET] "/packs/js/application-b610d75862aa1fd2e383.js.map"):
|
90
|
+
|
91
|
+
[ce1c4b7b-19e1-46e3-b1a6-f73dac82ec46]
|
92
|
+
|
93
|
+
F, [2021-07-20T13:54:02.207922 #14195] FATAL -- : [713e50a8-f7b5-4cf9-b21f-dafc41e19fb2]
|
94
|
+
|
95
|
+
[713e50a8-f7b5-4cf9-b21f-dafc41e19fb2] ActionController::RoutingError (No route matches [GET] "/packs/media/slick/ajax-loader-c5cd7f53.gif"):
|
96
|
+
|
97
|
+
[713e50a8-f7b5-4cf9-b21f-dafc41e19fb2]
|
98
|
+
|
99
|
+
F, [2021-07-20T13:54:02.267868 #14195] FATAL -- : [ff052d0f-281e-489c-bd80-5d30bb6e8115]
|
100
|
+
|
101
|
+
[ff052d0f-281e-489c-bd80-5d30bb6e8115] ActionController::RoutingError (No route matches [GET] "/packs/media/fonts/slick-b7c9e1e4.woff"):
|
102
|
+
|
103
|
+
[ff052d0f-281e-489c-bd80-5d30bb6e8115]
|
104
|
+
|
105
|
+
F, [2021-07-20T13:54:02.338087 #14195] FATAL -- : [303e39fa-3183-46f7-80fa-2e371385ad18]
|
106
|
+
|
107
|
+
[303e39fa-3183-46f7-80fa-2e371385ad18] ActionController::RoutingError (No route matches [GET] "/packs/media/fonts/slick-d41f55a7.ttf"):
|
108
|
+
|
109
|
+
[303e39fa-3183-46f7-80fa-2e371385ad18]
|
110
|
+
|
111
|
+
F, [2021-07-20T13:54:06.528087 #14195] FATAL -- : [1c41adf1-a49d-46e9-b945-91f5bbc3a596]
|
112
|
+
|
113
|
+
[1c41adf1-a49d-46e9-b945-91f5bbc3a596] ActionController::RoutingError (No route matches [GET] "/packs/js/application-b610d75862aa1fd2e383.js.map"):
|
114
|
+
|
115
|
+
[1c41adf1-a49d-46e9-b945-91f5bbc3a596]
|
116
|
+
|
117
|
+
F, [2021-07-20T13:54:06.725809 #14195] FATAL -- : [c52df05e-c1f8-4e3e-af2b-f19bd1197ab6]
|
118
|
+
|
119
|
+
[c52df05e-c1f8-4e3e-af2b-f19bd1197ab6] ActionController::RoutingError (No route matches [GET] "/packs/media/slick/ajax-loader-c5cd7f53.gif"):
|
120
|
+
|
121
|
+
[c52df05e-c1f8-4e3e-af2b-f19bd1197ab6]
|
122
|
+
|
123
|
+
F, [2021-07-20T13:54:06.778260 #14195] FATAL -- : [c5580b05-6b49-4be0-8e3f-4c2614a11b98]
|
124
|
+
|
125
|
+
[c5580b05-6b49-4be0-8e3f-4c2614a11b98] ActionController::RoutingError (No route matches [GET] "/packs/media/fonts/slick-b7c9e1e4.woff"):
|
126
|
+
|
127
|
+
[c5580b05-6b49-4be0-8e3f-4c2614a11b98]
|
128
|
+
|
129
|
+
F, [2021-07-20T13:54:06.934064 #14195] FATAL -- : [e67eff19-ae0e-4355-803a-c5577b6ba99a]
|
130
|
+
|
131
|
+
[e67eff19-ae0e-4355-803a-c5577b6ba99a] ActionController::RoutingError (No route matches [GET] "/packs/media/fonts/slick-d41f55a7.ttf"):
|
132
|
+
|
133
|
+
[e67eff19-ae0e-4355-803a-c5577b6ba99a]
|
134
|
+
|
135
|
+
F, [2021-07-20T14:12:02.274062 #14195] FATAL -- : [5aa25c62-b307-4822-b719-9651c7270166]
|
136
|
+
|
137
|
+
[5aa25c62-b307-4822-b719-9651c7270166] ActionController::RoutingError (No route matches [GET] "/favicon.ico"):
|
138
|
+
|
139
|
+
[5aa25c62-b307-4822-b719-9651c7270166]
|
140
|
+
|
141
|
+
F, [2021-07-20T14:34:35.516776 #14195] FATAL -- : [78bae128-d8c7-4fc8-a4c0-455c85b64198]
|
142
|
+
|
143
|
+
[78bae128-d8c7-4fc8-a4c0-455c85b64198] ActionController::RoutingError (No route matches [GET] "/.env"):
|
144
|
+
|
145
|
+
[78bae128-d8c7-4fc8-a4c0-455c85b64198]
|
146
|
+
|
147
|
+
F, [2021-07-20T14:34:35.912826 #14195] FATAL -- : [a920c07c-d9f5-4e0a-9510-343fe65ba791]
|
148
|
+
|
149
|
+
[a920c07c-d9f5-4e0a-9510-343fe65ba791] ActionController::RoutingError (No route matches [POST] "/"):
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
config/environments/production.rb
|
154
|
+
|
155
|
+
Rails.application.configure do
|
156
|
+
|
157
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
# Code is not reloaded between requests.
|
162
|
+
|
163
|
+
config.cache_classes = true
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
config.eager_load = true
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
config.consider_all_requests_local = false
|
174
|
+
|
175
|
+
config.action_controller.perform_caching = true
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
config.require_master_key = true
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
192
|
+
|
193
|
+
config.assets.compile = true
|
194
|
+
|
195
|
+
config.assets.initialize_on_precompile=false
|
196
|
+
|
197
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
198
|
+
|
199
|
+
# config.action_controller.asset_host = 'http://assets.example.com'
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
# Specifies the header that your server uses for sending files.
|
204
|
+
|
205
|
+
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
206
|
+
|
207
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
# Store uploaded files on the local file system (see config/storage.yml for options).
|
212
|
+
|
213
|
+
config.active_storage.service = :local
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
# Mount Action Cable outside main process or domain.
|
218
|
+
|
219
|
+
# config.action_cable.mount_path = nil
|
220
|
+
|
221
|
+
# config.action_cable.url = 'wss://example.com/cable'
|
222
|
+
|
223
|
+
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http://example.*/ ]
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
228
|
+
|
229
|
+
# config.force_ssl = true
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
# Use the lowest log level to ensure availability of diagnostic information
|
234
|
+
|
235
|
+
# when problems arise.
|
236
|
+
|
237
|
+
config.log_level = :error
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
# Prepend all log lines with the following tags.
|
242
|
+
|
243
|
+
config.log_tags = [ :request_id ]
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
# Use a different cache store in production.
|
248
|
+
|
249
|
+
# config.cache_store = :mem_cache_store
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
# Use a real queuing backend for Active Job (and separate queues per environment).
|
254
|
+
|
255
|
+
# config.active_job.queue_adapter = :resque
|
256
|
+
|
257
|
+
# config.active_job.queue_name_prefix = "アプリ名_production"
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
config.action_mailer.perform_caching = false
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
266
|
+
|
267
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
268
|
+
|
269
|
+
# config.action_mailer.raise_delivery_errors = false
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
274
|
+
|
275
|
+
# the I18n.default_locale when a translation cannot be found).
|
276
|
+
|
277
|
+
config.i18n.fallbacks = true
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
# Send deprecation notices to registered listeners.
|
282
|
+
|
283
|
+
config.active_support.deprecation = :notify
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
288
|
+
|
289
|
+
config.log_formatter = ::Logger::Formatter.new
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
# Use a different logger for distributed setups.
|
294
|
+
|
295
|
+
# require 'syslog/logger'
|
296
|
+
|
297
|
+
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
302
|
+
|
303
|
+
logger = ActiveSupport::Logger.new(STDOUT)
|
304
|
+
|
305
|
+
logger.formatter = config.log_formatter
|
306
|
+
|
307
|
+
config.logger = Logger.new("log/production.log", 5, 10 * 1024 * 1024)
|
308
|
+
|
309
|
+
end
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
# Do not dump schema after migrations.
|
314
|
+
|
315
|
+
config.active_record.dump_schema_after_migration = false
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
end
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
config/puma.rb
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
|
332
|
+
|
333
|
+
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
|
334
|
+
|
335
|
+
threads min_threads_count, max_threads_count
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
#port ENV.fetch("PORT") { 3000 }
|
340
|
+
|
341
|
+
bind "unix://#{Rails.root}/tmp/sockets/puma.sock"
|
342
|
+
|
343
|
+
# Specifies the `environment` that Puma will run in.
|
344
|
+
|
345
|
+
#
|
346
|
+
|
347
|
+
environment ENV.fetch("RAILS_ENV") { "development" }
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
# Specifies the `pidfile` that Puma will use.
|
352
|
+
|
353
|
+
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
# Allow puma to be restarted by `rails restart` command.
|
360
|
+
|
361
|
+
plugin :tmp_restart
|
362
|
+
|
363
|
+
```
|
60
364
|
|
61
365
|
|
62
366
|
|
63
367
|
```nginx
|
64
368
|
|
369
|
+
|
370
|
+
|
65
|
-
/etc/nginx/n
|
371
|
+
/etc/nginx/conf.d/rails.conf
|
66
|
-
|
67
|
-
|
372
|
+
|
68
|
-
|
69
|
-
# * Official English Documentation: http://nginx.org/en/docs/
|
70
|
-
|
71
|
-
# * Official Russian Documentation: http://nginx.org/ru/docs/
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
use
|
373
|
+
upstream puma {
|
76
|
-
|
77
|
-
|
374
|
+
|
78
|
-
|
79
|
-
error_log /var/log/nginx/error.log;
|
80
|
-
|
81
|
-
p
|
375
|
+
# pumaの設定で指定したsocketファイルを指定
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
376
|
+
|
86
|
-
|
377
|
+
|
378
|
+
|
87
|
-
|
379
|
+
server unix:///var//www/アプリ名/tmp/sockets/puma.sock;
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
380
|
+
|
92
|
-
|
93
|
-
|
381
|
+
|
94
382
|
|
95
383
|
}
|
96
384
|
|
97
385
|
|
98
386
|
|
99
|
-
http {
|
100
|
-
|
101
|
-
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
102
|
-
|
103
|
-
'$status $body_bytes_sent "$http_referer" '
|
104
|
-
|
105
|
-
'"$http_user_agent" "$http_x_forwarded_for"';
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
access_log /var/log/nginx/access.log main;
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
sendfile on;
|
114
|
-
|
115
|
-
tcp_nopush on;
|
116
|
-
|
117
|
-
tcp_nodelay on;
|
118
|
-
|
119
|
-
keepalive_timeout 65;
|
120
|
-
|
121
|
-
types_hash_max_size 4096;
|
122
|
-
|
123
|
-
client_max_body_size 20M;
|
124
|
-
|
125
|
-
include /etc/nginx/mime.types;
|
126
|
-
|
127
|
-
default_type application/octet-stream;
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
# Load modular configuration files from the /etc/nginx/conf.d directory.
|
132
|
-
|
133
|
-
# See http://nginx.org/en/docs/ngx_core_module.html#include
|
134
|
-
|
135
|
-
# for more information.
|
136
|
-
|
137
|
-
include /etc/nginx/conf.d/*.conf;
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
387
|
+
server {
|
142
|
-
|
388
|
+
|
143
|
-
|
389
|
+
# nginxが待ち受けしたいポートを指定
|
144
|
-
|
390
|
+
|
391
|
+
|
392
|
+
|
145
|
-
listen
|
393
|
+
listen 3000 default_server;
|
394
|
+
|
395
|
+
|
396
|
+
|
146
|
-
|
397
|
+
listen [::]:3000 default_server;
|
398
|
+
|
399
|
+
|
400
|
+
|
147
|
-
server_name
|
401
|
+
server_name puma;
|
402
|
+
|
403
|
+
|
404
|
+
|
148
|
-
|
405
|
+
location ~* .(html|scss|js)$ {
|
406
|
+
|
149
|
-
|
407
|
+
root /var/www/アプリ名/public;
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
408
|
+
|
154
|
-
|
155
|
-
include /etc/nginx/default.d/*.conf;
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
er
|
409
|
+
expires 10d;
|
160
|
-
|
410
|
+
|
161
|
-
|
411
|
+
access_log off;
|
412
|
+
|
413
|
+
break;
|
162
414
|
|
163
415
|
}
|
164
416
|
|
165
417
|
|
166
418
|
|
167
|
-
error_page 500 502 503 504 /50x.html;
|
168
|
-
|
169
|
-
|
419
|
+
location / {
|
420
|
+
|
170
|
-
|
421
|
+
proxy_read_timeout 300;
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
proxy_connect_timeout 300;
|
426
|
+
|
427
|
+
|
428
|
+
|
171
|
-
|
429
|
+
proxy_redirect off;
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
proxy_set_header Host $host;
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
# 上記server_name で設定した名前で指定
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
proxy_pass http://puma;
|
172
450
|
|
173
451
|
}
|
174
452
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
/etc/nginx/conf.d/rails.conf
|
182
|
-
|
183
|
-
upstream puma {
|
184
|
-
|
185
|
-
# pumaの設定で指定したsocketファイルを指定
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
server unix:///var//www/アプリ名/tmp/sockets/puma.sock;
|
190
|
-
|
191
|
-
|
192
|
-
|
193
453
|
}
|
194
454
|
|
195
|
-
|
196
|
-
|
197
|
-
server {
|
198
|
-
|
199
|
-
# nginxが待ち受けしたいポートを指定
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
listen 3000 default_server;
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
listen [::]:3000 default_server;
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
server_name puma;
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
location ~* .(html|scss|js)$ {
|
216
|
-
|
217
|
-
root /var/www/アプリ名/public;
|
218
|
-
|
219
|
-
expires 10d;
|
220
|
-
|
221
|
-
access_log off;
|
222
|
-
|
223
|
-
break;
|
224
|
-
|
225
|
-
}
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
location / {
|
230
|
-
|
231
|
-
proxy_read_timeout 300;
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
proxy_connect_timeout 300;
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
proxy_redirect off;
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
proxy_set_header Host $host;
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
# 上記server_name で設定した名前で指定
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
proxy_pass http://puma;
|
260
|
-
|
261
|
-
}
|
262
|
-
|
263
|
-
}
|
264
|
-
|
265
455
|
```
|
266
456
|
|
267
457
|
|
1
nginxのコード入れた
test
CHANGED
File without changes
|
test
CHANGED
@@ -48,8 +48,6 @@
|
|
48
48
|
|
49
49
|
|
50
50
|
|
51
|
-
|
52
|
-
|
53
51
|
```
|
54
52
|
|
55
53
|
|
@@ -58,332 +56,234 @@
|
|
58
56
|
|
59
57
|
|
60
58
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
```nginx
|
64
|
+
|
65
|
+
/etc/nginx/nginx.conf
|
66
|
+
|
67
|
+
# For more information on configuration, see:
|
68
|
+
|
69
|
+
# * Official English Documentation: http://nginx.org/en/docs/
|
70
|
+
|
71
|
+
# * Official Russian Documentation: http://nginx.org/ru/docs/
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
user nginx;
|
76
|
+
|
77
|
+
worker_processes auto;
|
78
|
+
|
79
|
+
error_log /var/log/nginx/error.log;
|
80
|
+
|
81
|
+
pid /run/nginx.pid;
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
|
86
|
+
|
87
|
+
include /usr/share/nginx/modules/*.conf;
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
events {
|
92
|
+
|
93
|
+
worker_connections 1024;
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
http {
|
100
|
+
|
101
|
+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
102
|
+
|
103
|
+
'$status $body_bytes_sent "$http_referer" '
|
104
|
+
|
105
|
+
'"$http_user_agent" "$http_x_forwarded_for"';
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
access_log /var/log/nginx/access.log main;
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
sendfile on;
|
114
|
+
|
115
|
+
tcp_nopush on;
|
116
|
+
|
117
|
+
tcp_nodelay on;
|
118
|
+
|
119
|
+
keepalive_timeout 65;
|
120
|
+
|
121
|
+
types_hash_max_size 4096;
|
122
|
+
|
123
|
+
client_max_body_size 20M;
|
124
|
+
|
125
|
+
include /etc/nginx/mime.types;
|
126
|
+
|
127
|
+
default_type application/octet-stream;
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
# Load modular configuration files from the /etc/nginx/conf.d directory.
|
132
|
+
|
133
|
+
# See http://nginx.org/en/docs/ngx_core_module.html#include
|
134
|
+
|
135
|
+
# for more information.
|
136
|
+
|
137
|
+
include /etc/nginx/conf.d/*.conf;
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
server {
|
142
|
+
|
143
|
+
listen 80;
|
144
|
+
|
145
|
+
listen [::]:80;
|
146
|
+
|
147
|
+
server_name _;
|
148
|
+
|
149
|
+
root /usr/share/nginx/html;
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
# Load configuration files for the default server block.
|
154
|
+
|
155
|
+
include /etc/nginx/default.d/*.conf;
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
error_page 404 /404.html;
|
160
|
+
|
161
|
+
location = /404.html {
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
error_page 500 502 503 504 /50x.html;
|
168
|
+
|
169
|
+
location = /50x.html {
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
/etc/nginx/conf.d/rails.conf
|
182
|
+
|
183
|
+
upstream puma {
|
184
|
+
|
185
|
+
# pumaの設定で指定したsocketファイルを指定
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
server unix:///var//www/アプリ名/tmp/sockets/puma.sock;
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
server {
|
198
|
+
|
199
|
+
# nginxが待ち受けしたいポートを指定
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
listen 3000 default_server;
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
listen [::]:3000 default_server;
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
server_name puma;
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
location ~* .(html|scss|js)$ {
|
216
|
+
|
217
|
+
root /var/www/アプリ名/public;
|
218
|
+
|
219
|
+
expires 10d;
|
220
|
+
|
221
|
+
access_log off;
|
222
|
+
|
223
|
+
break;
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
location / {
|
230
|
+
|
231
|
+
proxy_read_timeout 300;
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
proxy_connect_timeout 300;
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
proxy_redirect off;
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
proxy_set_header Host $host;
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
# 上記server_name で設定した名前で指定
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
proxy_pass http://puma;
|
260
|
+
|
261
|
+
}
|
262
|
+
|
263
|
+
}
|
264
|
+
|
265
|
+
```
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
### 試したこと
|
270
|
+
|
271
|
+
assetsファイルに問題があると考え、
|
272
|
+
|
273
|
+
2つのサーバーのyarn、nodeのバージョンが一致している事を確認した。
|
274
|
+
|
275
|
+
相違していたためバージョンを揃えて、再度
|
276
|
+
|
277
|
+
rails assets:precompile RAILS_ENV=production
|
278
|
+
|
279
|
+
をしたが直らなかった。
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
次にキャッシュが影響しているのではないかと考え、
|
152
284
|
|
153
285
|
config/environments/production.rb
|
154
286
|
|
155
|
-
Rails.application.configure do
|
156
|
-
|
157
|
-
# Settings specified here will take precedence over those in config/application.rb.
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
# Code is not reloaded between requests.
|
162
|
-
|
163
|
-
config.cache_classes = true
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
config.eager_load = true
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
config.consider_all_requests_local = false
|
174
|
-
|
175
|
-
config.action_controller.perform_caching = true
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
config.require_master_key = true
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
192
|
-
|
193
|
-
config.assets.compile = true
|
194
|
-
|
195
|
-
config.assets.initialize_on_precompile=false
|
196
|
-
|
197
|
-
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
198
|
-
|
199
|
-
# config.action_controller.asset_host = 'http://assets.example.com'
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
# Specifies the header that your server uses for sending files.
|
204
|
-
|
205
|
-
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
206
|
-
|
207
|
-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
# Store uploaded files on the local file system (see config/storage.yml for options).
|
212
|
-
|
213
|
-
config.active_storage.service = :local
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
# Mount Action Cable outside main process or domain.
|
218
|
-
|
219
|
-
# config.action_cable.mount_path = nil
|
220
|
-
|
221
|
-
# config.action_cable.url = 'wss://example.com/cable'
|
222
|
-
|
223
|
-
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http://example.*/ ]
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
228
|
-
|
229
|
-
# config.force_ssl = true
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
# Use the lowest log level to ensure availability of diagnostic information
|
234
|
-
|
235
|
-
# when problems arise.
|
236
|
-
|
237
|
-
config.log_level = :error
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
# Prepend all log lines with the following tags.
|
242
|
-
|
243
|
-
config.log_tags = [ :request_id ]
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
# Use a different cache store in production.
|
248
|
-
|
249
|
-
# config.cache_store = :mem_cache_store
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
# Use a real queuing backend for Active Job (and separate queues per environment).
|
254
|
-
|
255
|
-
# config.active_job.queue_adapter = :resque
|
256
|
-
|
257
|
-
# config.active_job.queue_name_prefix = "アプリ名_production"
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
config.action_mailer.perform_caching = false
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
# Ignore bad email addresses and do not raise email delivery errors.
|
266
|
-
|
267
|
-
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
268
|
-
|
269
|
-
# config.action_mailer.raise_delivery_errors = false
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
274
|
-
|
275
|
-
# the I18n.default_locale when a translation cannot be found).
|
276
|
-
|
277
|
-
config.i18n.fallbacks = true
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
# Send deprecation notices to registered listeners.
|
282
|
-
|
283
|
-
config.active_support.deprecation = :notify
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
# Use default logging formatter so that PID and timestamp are not suppressed.
|
288
|
-
|
289
|
-
config.log_formatter = ::Logger::Formatter.new
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
# Use a different logger for distributed setups.
|
294
|
-
|
295
|
-
# require 'syslog/logger'
|
296
|
-
|
297
|
-
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
302
|
-
|
303
|
-
logger = ActiveSupport::Logger.new(STDOUT)
|
304
|
-
|
305
|
-
logger.formatter = config.log_formatter
|
306
|
-
|
307
|
-
config.logger = Logger.new("log/production.log", 5, 10 * 1024 * 1024)
|
308
|
-
|
309
|
-
end
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
# Do not dump schema after migrations.
|
314
|
-
|
315
|
-
config.active_record.dump_schema_after_migration = false
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
end
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
config/puma.rb
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
|
332
|
-
|
333
|
-
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
|
334
|
-
|
335
|
-
threads min_threads_count, max_threads_count
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
#port ENV.fetch("PORT") { 3000 }
|
340
|
-
|
341
|
-
bind "unix://#{Rails.root}/tmp/sockets/puma.sock"
|
342
|
-
|
343
|
-
# Specifies the `environment` that Puma will run in.
|
344
|
-
|
345
|
-
#
|
346
|
-
|
347
|
-
environment ENV.fetch("RAILS_ENV") { "development" }
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
# Specifies the `pidfile` that Puma will use.
|
352
|
-
|
353
|
-
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
# Allow puma to be restarted by `rails restart` command.
|
360
|
-
|
361
|
-
plugin :tmp_restart
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
```
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
### 試したこと
|
370
|
-
|
371
|
-
assetsファイルに問題があると考え、
|
372
|
-
|
373
|
-
2つのサーバーのyarn、nodeのバージョンが一致している事を確認した。
|
374
|
-
|
375
|
-
相違していたためバージョンを揃えて、再度
|
376
|
-
|
377
|
-
rails assets:precompile RAILS_ENV=production
|
378
|
-
|
379
|
-
をしたが直らなかった。
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
次にキャッシュが影響しているのではないかと考え、
|
384
|
-
|
385
|
-
config/environments/production.rb
|
386
|
-
|
387
287
|
の
|
388
288
|
|
389
289
|
config.cache_classes = true
|