質問編集履歴
8
再修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,14 +1,76 @@
|
|
1
|
-
# 本番環境で
|
1
|
+
# rails5+nginx+unicorn本番環境でアプリのルートファイルが表示できない
|
2
2
|
|
3
3
|
|
4
4
|
|
5
5
|
app/views以下に設定したrootページが表示できないです。
|
6
6
|
|
7
|
-
試しにapp_name/public/にindex.htmlを置くとapp_name/public/index.htmlは表示されpublic/assets以降も表示できるような状況です。
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
試しにapp_name/public/にindex.htmlを置くとapp_name/public/index.htmlは表示されpublic/assets以降も表示できるような状況ですが、app_name/public/からindex.htmlを削除して、本来表示したいroutesに設定したhome#indexが表示せずに403 Forbiddenと返ってきます。
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
|
15
|
+
rails server -e production
|
16
|
+
|
17
|
+
```
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
ローカルで本番環境を確認してもrootで設定したファイルが表示されます。
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
**nginx/error.log**エラーログは以下です。
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
```
|
32
|
+
|
33
|
+
2018/05/12 12:31:47 [error] 13982#13982: *1 directory index of "/home/user_name/rails_app/public/" is forbidden, client: ***.*.***.***, server: example.com, request: "GET / HTTP/2.0", host: "example.com"
|
34
|
+
|
35
|
+
```
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
/home/user_name/rails_app/public配下にindex.htmlを置くとページは表示される状況です。
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
publicのパーミッションは以下になります。
|
44
|
+
|
45
|
+
```
|
46
|
+
|
47
|
+
drwxrwxr-x 3 nginx user 4096 5月 11 15:53
|
48
|
+
|
49
|
+
```
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
**rails_app/config/routes.rb**
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
```Ruby
|
60
|
+
|
61
|
+
Rails.application.routes.draw do
|
62
|
+
|
63
|
+
get 'home/index'
|
64
|
+
|
65
|
+
root :to => 'home#index'
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
```
|
72
|
+
|
73
|
+
|
12
74
|
|
13
75
|
|
14
76
|
|
@@ -20,7 +82,7 @@
|
|
20
82
|
|
21
83
|
|
22
84
|
|
23
|
-
nginx.conf
|
85
|
+
**nginx.conf**
|
24
86
|
|
25
87
|
|
26
88
|
|
@@ -222,248 +284,206 @@
|
|
222
284
|
|
223
285
|
|
224
286
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
287
|
+
---
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
**environments/production.rb**は以下の設定です。
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
```ruby
|
298
|
+
|
299
|
+
Rails.application.configure do
|
300
|
+
|
301
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
# Code is not reloaded between requests.
|
306
|
+
|
307
|
+
config.cache_classes = true
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
# Eager load code on boot. This eager loads most of Rails and
|
312
|
+
|
313
|
+
# your application in memory, allowing both threaded web servers
|
314
|
+
|
315
|
+
# and those relying on copy on write to perform better.
|
316
|
+
|
317
|
+
# Rake tasks automatically ignore this option for performance.
|
318
|
+
|
319
|
+
config.eager_load = true
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
# Full error reports are disabled and caching is turned on.
|
324
|
+
|
325
|
+
config.consider_all_requests_local = false
|
326
|
+
|
327
|
+
config.action_controller.perform_caching = true
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
|
332
|
+
|
333
|
+
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
|
334
|
+
|
335
|
+
# config.require_master_key = true
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
# Disable serving static files from the `/public` folder by default since
|
340
|
+
|
341
|
+
# Apache or NGINX already handles this.
|
342
|
+
|
343
|
+
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
# Compress JavaScripts and CSS.
|
348
|
+
|
349
|
+
config.assets.js_compressor = :uglifier
|
350
|
+
|
351
|
+
# config.assets.css_compressor = :sass
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
356
|
+
|
357
|
+
config.assets.compile = false
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
366
|
+
|
367
|
+
# config.action_controller.asset_host = 'http://assets.example.com'
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
# Specifies the header that your server uses for sending files.
|
372
|
+
|
373
|
+
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
374
|
+
|
375
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
# Store uploaded files on the local file system (see config/storage.yml for options)
|
380
|
+
|
381
|
+
config.active_storage.service = :local
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
# Mount Action Cable outside main process or domain
|
386
|
+
|
387
|
+
# config.action_cable.mount_path = nil
|
388
|
+
|
389
|
+
# config.action_cable.url = 'wss://example.com/cable'
|
390
|
+
|
391
|
+
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http://example.*/ ]
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
396
|
+
|
397
|
+
config.force_ssl = true
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
# Use the lowest log level to ensure availability of diagnostic information
|
402
|
+
|
403
|
+
# when problems arise.
|
404
|
+
|
405
|
+
config.log_level = :debug
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
# Prepend all log lines with the following tags.
|
410
|
+
|
411
|
+
config.log_tags = [ :request_id ]
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
# Use a different cache store in production.
|
416
|
+
|
417
|
+
# config.cache_store = :mem_cache_store
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
# Use a real queuing backend for Active Job (and separate queues per environment)
|
422
|
+
|
423
|
+
# config.active_job.queue_adapter = :resque
|
424
|
+
|
425
|
+
# config.active_job.queue_name_prefix = "appname_#{Rails.env}"
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
config.action_mailer.perform_caching = false
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
434
|
+
|
435
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
436
|
+
|
437
|
+
# config.action_mailer.raise_delivery_errors = false
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
442
|
+
|
443
|
+
# the I18n.default_locale when a translation cannot be found).
|
444
|
+
|
445
|
+
config.i18n.fallbacks = true
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
# Send deprecation notices to registered listeners.
|
450
|
+
|
451
|
+
config.active_support.deprecation = :notify
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
456
|
+
|
457
|
+
config.log_formatter = ::Logger::Formatter.new
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
# Use a different logger for distributed setups.
|
462
|
+
|
463
|
+
# require 'syslog/logger'
|
464
|
+
|
465
|
+
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
470
|
+
|
471
|
+
logger = ActiveSupport::Logger.new(STDOUT)
|
472
|
+
|
473
|
+
logger.formatter = config.log_formatter
|
474
|
+
|
475
|
+
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
476
|
+
|
477
|
+
end
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
# Do not dump schema after migrations.
|
482
|
+
|
483
|
+
config.active_record.dump_schema_after_migration = false
|
238
484
|
|
239
485
|
end
|
240
486
|
|
241
487
|
|
242
488
|
|
243
489
|
```
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
nginx/error.logの内容は以下になります。
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
```
|
252
|
-
|
253
|
-
2018/05/12 12:31:47 [error] 13982#13982: *1 directory index of "/home/user_name/rails_app/public/" is forbidden, client: ***.*.***.***, server: example.com, request: "GET / HTTP/2.0", host: "example.com"
|
254
|
-
|
255
|
-
```
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
/home/user_name/rails_app/public配下にindex.htmlを置くとページは表示される状況です。
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
publicのパーミッションは以下になります。
|
264
|
-
|
265
|
-
```
|
266
|
-
|
267
|
-
drwxrwxr-x 3 nginx user 4096 5月 11 15:53
|
268
|
-
|
269
|
-
```
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
**environments/production.rb**は以下の設定です。
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
```ruby
|
278
|
-
|
279
|
-
Rails.application.configure do
|
280
|
-
|
281
|
-
# Settings specified here will take precedence over those in config/application.rb.
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
# Code is not reloaded between requests.
|
286
|
-
|
287
|
-
config.cache_classes = true
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
# Eager load code on boot. This eager loads most of Rails and
|
292
|
-
|
293
|
-
# your application in memory, allowing both threaded web servers
|
294
|
-
|
295
|
-
# and those relying on copy on write to perform better.
|
296
|
-
|
297
|
-
# Rake tasks automatically ignore this option for performance.
|
298
|
-
|
299
|
-
config.eager_load = true
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
# Full error reports are disabled and caching is turned on.
|
304
|
-
|
305
|
-
config.consider_all_requests_local = false
|
306
|
-
|
307
|
-
config.action_controller.perform_caching = true
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
|
312
|
-
|
313
|
-
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
|
314
|
-
|
315
|
-
# config.require_master_key = true
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
# Disable serving static files from the `/public` folder by default since
|
320
|
-
|
321
|
-
# Apache or NGINX already handles this.
|
322
|
-
|
323
|
-
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
# Compress JavaScripts and CSS.
|
328
|
-
|
329
|
-
config.assets.js_compressor = :uglifier
|
330
|
-
|
331
|
-
# config.assets.css_compressor = :sass
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
336
|
-
|
337
|
-
config.assets.compile = false
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
346
|
-
|
347
|
-
# config.action_controller.asset_host = 'http://assets.example.com'
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
# Specifies the header that your server uses for sending files.
|
352
|
-
|
353
|
-
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
354
|
-
|
355
|
-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
# Store uploaded files on the local file system (see config/storage.yml for options)
|
360
|
-
|
361
|
-
config.active_storage.service = :local
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
# Mount Action Cable outside main process or domain
|
366
|
-
|
367
|
-
# config.action_cable.mount_path = nil
|
368
|
-
|
369
|
-
# config.action_cable.url = 'wss://example.com/cable'
|
370
|
-
|
371
|
-
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http://example.*/ ]
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
376
|
-
|
377
|
-
config.force_ssl = true
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
# Use the lowest log level to ensure availability of diagnostic information
|
382
|
-
|
383
|
-
# when problems arise.
|
384
|
-
|
385
|
-
config.log_level = :debug
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
# Prepend all log lines with the following tags.
|
390
|
-
|
391
|
-
config.log_tags = [ :request_id ]
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
# Use a different cache store in production.
|
396
|
-
|
397
|
-
# config.cache_store = :mem_cache_store
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
# Use a real queuing backend for Active Job (and separate queues per environment)
|
402
|
-
|
403
|
-
# config.active_job.queue_adapter = :resque
|
404
|
-
|
405
|
-
# config.active_job.queue_name_prefix = "appname_#{Rails.env}"
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
config.action_mailer.perform_caching = false
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
# Ignore bad email addresses and do not raise email delivery errors.
|
414
|
-
|
415
|
-
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
416
|
-
|
417
|
-
# config.action_mailer.raise_delivery_errors = false
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
422
|
-
|
423
|
-
# the I18n.default_locale when a translation cannot be found).
|
424
|
-
|
425
|
-
config.i18n.fallbacks = true
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
# Send deprecation notices to registered listeners.
|
430
|
-
|
431
|
-
config.active_support.deprecation = :notify
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
# Use default logging formatter so that PID and timestamp are not suppressed.
|
436
|
-
|
437
|
-
config.log_formatter = ::Logger::Formatter.new
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
# Use a different logger for distributed setups.
|
442
|
-
|
443
|
-
# require 'syslog/logger'
|
444
|
-
|
445
|
-
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
450
|
-
|
451
|
-
logger = ActiveSupport::Logger.new(STDOUT)
|
452
|
-
|
453
|
-
logger.formatter = config.log_formatter
|
454
|
-
|
455
|
-
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
456
|
-
|
457
|
-
end
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
# Do not dump schema after migrations.
|
462
|
-
|
463
|
-
config.active_record.dump_schema_after_migration = false
|
464
|
-
|
465
|
-
end
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
```
|
7
修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rails+nginx+unicorn本番環境でアプリのルートファイルが表示できません。
|
1
|
+
rails5+nginx+unicorn本番環境でアプリのルートファイルが表示できません。
|
test
CHANGED
File without changes
|
6
情報追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -267,3 +267,203 @@
|
|
267
267
|
drwxrwxr-x 3 nginx user 4096 5月 11 15:53
|
268
268
|
|
269
269
|
```
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
**environments/production.rb**は以下の設定です。
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
```ruby
|
278
|
+
|
279
|
+
Rails.application.configure do
|
280
|
+
|
281
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
# Code is not reloaded between requests.
|
286
|
+
|
287
|
+
config.cache_classes = true
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
# Eager load code on boot. This eager loads most of Rails and
|
292
|
+
|
293
|
+
# your application in memory, allowing both threaded web servers
|
294
|
+
|
295
|
+
# and those relying on copy on write to perform better.
|
296
|
+
|
297
|
+
# Rake tasks automatically ignore this option for performance.
|
298
|
+
|
299
|
+
config.eager_load = true
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
# Full error reports are disabled and caching is turned on.
|
304
|
+
|
305
|
+
config.consider_all_requests_local = false
|
306
|
+
|
307
|
+
config.action_controller.perform_caching = true
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
|
312
|
+
|
313
|
+
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
|
314
|
+
|
315
|
+
# config.require_master_key = true
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
# Disable serving static files from the `/public` folder by default since
|
320
|
+
|
321
|
+
# Apache or NGINX already handles this.
|
322
|
+
|
323
|
+
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
# Compress JavaScripts and CSS.
|
328
|
+
|
329
|
+
config.assets.js_compressor = :uglifier
|
330
|
+
|
331
|
+
# config.assets.css_compressor = :sass
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
336
|
+
|
337
|
+
config.assets.compile = false
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
346
|
+
|
347
|
+
# config.action_controller.asset_host = 'http://assets.example.com'
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
# Specifies the header that your server uses for sending files.
|
352
|
+
|
353
|
+
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
354
|
+
|
355
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
# Store uploaded files on the local file system (see config/storage.yml for options)
|
360
|
+
|
361
|
+
config.active_storage.service = :local
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
# Mount Action Cable outside main process or domain
|
366
|
+
|
367
|
+
# config.action_cable.mount_path = nil
|
368
|
+
|
369
|
+
# config.action_cable.url = 'wss://example.com/cable'
|
370
|
+
|
371
|
+
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http://example.*/ ]
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
376
|
+
|
377
|
+
config.force_ssl = true
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
# Use the lowest log level to ensure availability of diagnostic information
|
382
|
+
|
383
|
+
# when problems arise.
|
384
|
+
|
385
|
+
config.log_level = :debug
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
# Prepend all log lines with the following tags.
|
390
|
+
|
391
|
+
config.log_tags = [ :request_id ]
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
# Use a different cache store in production.
|
396
|
+
|
397
|
+
# config.cache_store = :mem_cache_store
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
# Use a real queuing backend for Active Job (and separate queues per environment)
|
402
|
+
|
403
|
+
# config.active_job.queue_adapter = :resque
|
404
|
+
|
405
|
+
# config.active_job.queue_name_prefix = "appname_#{Rails.env}"
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
config.action_mailer.perform_caching = false
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
414
|
+
|
415
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
416
|
+
|
417
|
+
# config.action_mailer.raise_delivery_errors = false
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
422
|
+
|
423
|
+
# the I18n.default_locale when a translation cannot be found).
|
424
|
+
|
425
|
+
config.i18n.fallbacks = true
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
# Send deprecation notices to registered listeners.
|
430
|
+
|
431
|
+
config.active_support.deprecation = :notify
|
432
|
+
|
433
|
+
|
434
|
+
|
435
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
436
|
+
|
437
|
+
config.log_formatter = ::Logger::Formatter.new
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
# Use a different logger for distributed setups.
|
442
|
+
|
443
|
+
# require 'syslog/logger'
|
444
|
+
|
445
|
+
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
450
|
+
|
451
|
+
logger = ActiveSupport::Logger.new(STDOUT)
|
452
|
+
|
453
|
+
logger.formatter = config.log_formatter
|
454
|
+
|
455
|
+
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
456
|
+
|
457
|
+
end
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
# Do not dump schema after migrations.
|
462
|
+
|
463
|
+
config.active_record.dump_schema_after_migration = false
|
464
|
+
|
465
|
+
end
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
```
|
5
文面改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,31 +2,103 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
nginxでroot設定は/home/user/app_name/public
|
6
|
-
|
7
|
-
|
5
|
+
app/views以下に設定したrootページが表示できないです。
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
|
11
|
-
試しにapp_name/public/にindex.htmlを置くとapp_name/public/index.htmlは表示されpublic/assets以降も表示でき
|
7
|
+
試しにapp_name/public/にindex.htmlを置くとapp_name/public/index.htmlは表示されpublic/assets以降も表示できるような状況です。
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
|
9
|
+
|
10
|
+
|
15
|
-
app/
|
11
|
+
しかし、app_name/public/からindex.htmlを削除して、本来表示したいroutesに設定したhome#indexが表示せずに403 Forbiddenと返ってきます。
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
|
13
|
+
|
14
|
+
|
19
|
-
|
15
|
+
---
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
|
17
|
+
|
18
|
+
|
23
|
-
nginxで
|
19
|
+
nginxで.confは以下の3つで設定しています。
|
20
|
+
|
21
|
+
|
22
|
+
|
24
|
-
|
23
|
+
nginx.conf
|
25
|
-
|
26
|
-
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
-
```
|
27
|
+
```
|
28
|
+
|
28
|
-
|
29
|
+
user nginx;
|
30
|
+
|
29
|
-
|
31
|
+
worker_processes 1;
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
error_log /var/log/nginx/error.log warn;
|
36
|
+
|
37
|
+
pid /var/run/nginx.pid;
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
events {
|
44
|
+
|
45
|
+
worker_connections 1024;
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
http {
|
54
|
+
|
55
|
+
include /etc/nginx/mime.types;
|
56
|
+
|
57
|
+
default_type application/octet-stream;
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
62
|
+
|
63
|
+
'$status $body_bytes_sent "$http_referer" '
|
64
|
+
|
65
|
+
'"$http_user_agent" "$http_x_forwarded_for"';
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
access_log /var/log/nginx/access.log main;
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
sendfile on;
|
74
|
+
|
75
|
+
#tcp_nopush on;
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
keepalive_timeout 65;
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
#gzip on;
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
include /etc/nginx/conf.d/*.conf;
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
```
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
**htpps.conf**
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
```
|
30
102
|
|
31
103
|
map $http_upgrade $connection_upgrade {
|
32
104
|
|
@@ -84,6 +156,18 @@
|
|
84
156
|
|
85
157
|
|
86
158
|
|
159
|
+
```
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
**rails.conf**
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
```
|
170
|
+
|
87
171
|
upstream unicorn {
|
88
172
|
|
89
173
|
server unix:/home/user_name/rails_app/tmp/unicorn.sock;
|
@@ -138,7 +222,9 @@
|
|
138
222
|
|
139
223
|
|
140
224
|
|
225
|
+
|
226
|
+
|
141
|
-
**ra
|
227
|
+
**rails_app/config/routes.rb**
|
142
228
|
|
143
229
|
|
144
230
|
|
@@ -162,4 +248,22 @@
|
|
162
248
|
|
163
249
|
|
164
250
|
|
165
|
-
|
251
|
+
```
|
252
|
+
|
253
|
+
2018/05/12 12:31:47 [error] 13982#13982: *1 directory index of "/home/user_name/rails_app/public/" is forbidden, client: ***.*.***.***, server: example.com, request: "GET / HTTP/2.0", host: "example.com"
|
254
|
+
|
255
|
+
```
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
/home/user_name/rails_app/public配下にindex.htmlを置くとページは表示される状況です。
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
publicのパーミッションは以下になります。
|
264
|
+
|
265
|
+
```
|
266
|
+
|
267
|
+
drwxrwxr-x 3 nginx user 4096 5月 11 15:53
|
268
|
+
|
269
|
+
```
|
4
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,11 +2,9 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
nginxでroot設定は
|
5
|
+
nginxでroot設定は/home/user/app_name/public
|
6
6
|
|
7
|
-
/home/user/app_name/public
|
8
|
-
|
9
|
-
|
7
|
+
にして、app/views/以下のディレクトリを表示させるのだと思うのですが、routesに設定したhome#indexを表示しません。
|
10
8
|
|
11
9
|
|
12
10
|
|
3
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
+
nginxでroot設定は```
|
6
|
+
|
7
|
+
/home/user/app_name/public
|
8
|
+
|
5
|
-
|
9
|
+
```にして、app/views/以下のディレクトリを表示させるのだと思うのですが、routesに設定したhome#indexを表示しません。
|
6
10
|
|
7
11
|
|
8
12
|
|
2
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rails+nginx本番環境の
|
1
|
+
rails+nginx+unicorn本番環境でアプリのルートファイルが表示できません。
|
test
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
ものすごく初歩的なことでなのか検索などして調べても該当する内容を見つけれなかったので質問させてください。
|
2
|
-
|
3
|
-
|
4
|
-
|
5
1
|
# 本番環境でapp配下に設定したrootを表示したい
|
6
2
|
|
7
3
|
|
@@ -10,7 +6,7 @@
|
|
10
6
|
|
11
7
|
|
12
8
|
|
13
|
-
試しにapp_name/public/にindex.htmlを置くとapp_name/public/index.htmlは表示されます。
|
9
|
+
試しにapp_name/public/にindex.htmlを置くとapp_name/public/index.htmlは表示されpublic/assets以降も表示できます。
|
14
10
|
|
15
11
|
|
16
12
|
|
1
情報追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,25 +22,119 @@
|
|
22
22
|
|
23
23
|
|
24
24
|
|
25
|
-
nginxで以下のように設定しています。
|
25
|
+
nginxでhttps.confで以下のように設定しています。
|
26
26
|
|
27
27
|
|
28
28
|
|
29
29
|
```
|
30
30
|
|
31
|
+
|
32
|
+
|
31
|
-
|
33
|
+
map $http_upgrade $connection_upgrade {
|
34
|
+
|
35
|
+
default upgrade;
|
36
|
+
|
37
|
+
'' close;
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
server {
|
42
|
+
|
43
|
+
listen 443 ssl http2;
|
44
|
+
|
45
|
+
server_name example.com;
|
32
46
|
|
33
47
|
|
34
48
|
|
35
|
-
location / {
|
49
|
+
location / {
|
36
50
|
|
37
|
-
root /home/user
|
51
|
+
root /home/user_name/rails_app/public;
|
38
52
|
|
39
53
|
index index.html index.htm;
|
40
54
|
|
41
55
|
}
|
42
56
|
|
43
57
|
|
58
|
+
|
59
|
+
ssl_protocols TLSv1.2;
|
60
|
+
|
61
|
+
ssl_ciphers EECDH+AESGCM:EECDH+AES;
|
62
|
+
|
63
|
+
ssl_ecdh_curve prime256v1;
|
64
|
+
|
65
|
+
ssl_prefer_server_ciphers on;
|
66
|
+
|
67
|
+
ssl_session_cache shared:SSL:10m;
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
|
72
|
+
|
73
|
+
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
error_page 500 502 503 504 /50x.html;
|
78
|
+
|
79
|
+
location = /50x.html {
|
80
|
+
|
81
|
+
root /home/user_name/rails_app/public;
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
upstream unicorn {
|
90
|
+
|
91
|
+
server unix:/home/user_name/rails_app/tmp/unicorn.sock;
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
server {
|
98
|
+
|
99
|
+
listen 80;
|
100
|
+
|
101
|
+
server_name example.com;
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
access_log /var/log/nginx/access.log;
|
106
|
+
|
107
|
+
error_log /var/log/nginx/error.log;
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
root /home/user_name/rails_app/public;
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
client_max_body_size 100m;
|
116
|
+
|
117
|
+
error_page 404 /404.html;
|
118
|
+
|
119
|
+
error_page 500 502 503 504 /500.html;
|
120
|
+
|
121
|
+
try_files $uri/index.html $uri @unicorn;
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
location @unicorn {
|
126
|
+
|
127
|
+
proxy_set_header X-Real-IP $remote_addr;
|
128
|
+
|
129
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
130
|
+
|
131
|
+
proxy_set_header Host $http_host;
|
132
|
+
|
133
|
+
proxy_pass http://unicorn;
|
134
|
+
|
135
|
+
}
|
136
|
+
|
137
|
+
}
|
44
138
|
|
45
139
|
```
|
46
140
|
|
@@ -50,10 +144,24 @@
|
|
50
144
|
|
51
145
|
|
52
146
|
|
53
|
-
|
147
|
+
```Ruby
|
54
148
|
|
55
|
-
|
149
|
+
Rails.application.routes.draw do
|
56
150
|
|
57
|
-
|
151
|
+
get 'home/index'
|
58
152
|
|
59
|
-
home#index
|
153
|
+
root :to => 'home#index'
|
154
|
+
|
155
|
+
end
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
```
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
nginx/error.logの内容は以下になります。
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
2018/05/11 12:51:06 [error] 10585#10585: *7 directory index of "/home/user_name/rails_app/public" is forbidden, client: ***.**.*.*, server: example.com, request: "GET / HTTP/2.0", host: "example.com"
|