質問編集履歴
3
nginx書き忘れ
title
CHANGED
File without changes
|
body
CHANGED
@@ -243,6 +243,7 @@
|
|
243
243
|
をfalseにしてみたが直らなかった。
|
244
244
|
|
245
245
|
### 補足情報(FW/ツールのバージョンなど)
|
246
|
+
nginx
|
246
247
|
Rails 6.1.3.1
|
247
248
|
ruby 3.0.0p0
|
248
249
|
Bundler version 2.2.16
|
2
nginxのコード入れた
title
CHANGED
File without changes
|
body
CHANGED
@@ -27,67 +27,162 @@
|
|
27
27
|
|
28
28
|
### 該当のソースコード
|
29
29
|
|
30
|
+
```ruby
|
31
|
+
ruby
|
32
|
+
log/production.log
|
33
|
+
[af1fe402-43d0-4797-900d-096e58574a44] ActionController::RoutingError (No route matches [GET] "/packs/media/slick/ajax-loader-c5cd7f53.gif"):
|
34
|
+
[af1fe402-43d0-4797-900d-096e58574a44]
|
35
|
+
F, [2021-07-20T13:53:30.078738 #14195] FATAL -- : [0eec3015-2980-4d50-88ea-dbdd38eee56e]
|
36
|
+
[0eec3015-2980-4d50-88ea-dbdd38eee56e] ActionController::RoutingError (No route matches [GET] "/packs/media/fonts/slick-d41f55a7.ttf"):
|
37
|
+
[0eec3015-2980-4d50-88ea-dbdd38eee56e]
|
38
|
+
F, [2021-07-20T13:53:36.578798 #14195] FATAL -- : [9170e9f1-6e53-4513-a842-5eb6b2a60fd6]
|
39
|
+
[9170e9f1-6e53-4513-a842-5eb6b2a60fd6] ActionController::RoutingError (No route matches [GET] "/packs/media/slick/ajax-loader-c5cd7f53.gif"):
|
40
|
+
[9170e9f1-6e53-4513-a842-5eb6b2a60fd6]
|
41
|
+
F, [2021-07-20T13:53:36.716955 #14195] FATAL -- : [45afdf57-8b00-43cf-93e7-b113b7a56154]
|
42
|
+
[45afdf57-8b00-43cf-93e7-b113b7a56154] ActionController::RoutingError (No route matches [GET] "/packs/media/fonts/slick-d41f55a7.ttf"):
|
43
|
+
[45afdf57-8b00-43cf-93e7-b113b7a56154]
|
44
|
+
F, [2021-07-20T13:54:02.049332 #14195] FATAL -- : [ce1c4b7b-19e1-46e3-b1a6-f73dac82ec46]
|
45
|
+
[ce1c4b7b-19e1-46e3-b1a6-f73dac82ec46] ActionController::RoutingError (No route matches [GET] "/packs/js/application-b610d75862aa1fd2e383.js.map"):
|
46
|
+
[ce1c4b7b-19e1-46e3-b1a6-f73dac82ec46]
|
47
|
+
F, [2021-07-20T13:54:02.207922 #14195] FATAL -- : [713e50a8-f7b5-4cf9-b21f-dafc41e19fb2]
|
48
|
+
[713e50a8-f7b5-4cf9-b21f-dafc41e19fb2] ActionController::RoutingError (No route matches [GET] "/packs/media/slick/ajax-loader-c5cd7f53.gif"):
|
49
|
+
[713e50a8-f7b5-4cf9-b21f-dafc41e19fb2]
|
50
|
+
F, [2021-07-20T13:54:02.267868 #14195] FATAL -- : [ff052d0f-281e-489c-bd80-5d30bb6e8115]
|
51
|
+
[ff052d0f-281e-489c-bd80-5d30bb6e8115] ActionController::RoutingError (No route matches [GET] "/packs/media/fonts/slick-b7c9e1e4.woff"):
|
52
|
+
[ff052d0f-281e-489c-bd80-5d30bb6e8115]
|
53
|
+
F, [2021-07-20T13:54:02.338087 #14195] FATAL -- : [303e39fa-3183-46f7-80fa-2e371385ad18]
|
54
|
+
[303e39fa-3183-46f7-80fa-2e371385ad18] ActionController::RoutingError (No route matches [GET] "/packs/media/fonts/slick-d41f55a7.ttf"):
|
55
|
+
[303e39fa-3183-46f7-80fa-2e371385ad18]
|
56
|
+
F, [2021-07-20T13:54:06.528087 #14195] FATAL -- : [1c41adf1-a49d-46e9-b945-91f5bbc3a596]
|
57
|
+
[1c41adf1-a49d-46e9-b945-91f5bbc3a596] ActionController::RoutingError (No route matches [GET] "/packs/js/application-b610d75862aa1fd2e383.js.map"):
|
58
|
+
[1c41adf1-a49d-46e9-b945-91f5bbc3a596]
|
59
|
+
F, [2021-07-20T13:54:06.725809 #14195] FATAL -- : [c52df05e-c1f8-4e3e-af2b-f19bd1197ab6]
|
60
|
+
[c52df05e-c1f8-4e3e-af2b-f19bd1197ab6] ActionController::RoutingError (No route matches [GET] "/packs/media/slick/ajax-loader-c5cd7f53.gif"):
|
61
|
+
[c52df05e-c1f8-4e3e-af2b-f19bd1197ab6]
|
62
|
+
F, [2021-07-20T13:54:06.778260 #14195] FATAL -- : [c5580b05-6b49-4be0-8e3f-4c2614a11b98]
|
63
|
+
[c5580b05-6b49-4be0-8e3f-4c2614a11b98] ActionController::RoutingError (No route matches [GET] "/packs/media/fonts/slick-b7c9e1e4.woff"):
|
64
|
+
[c5580b05-6b49-4be0-8e3f-4c2614a11b98]
|
65
|
+
F, [2021-07-20T13:54:06.934064 #14195] FATAL -- : [e67eff19-ae0e-4355-803a-c5577b6ba99a]
|
66
|
+
[e67eff19-ae0e-4355-803a-c5577b6ba99a] ActionController::RoutingError (No route matches [GET] "/packs/media/fonts/slick-d41f55a7.ttf"):
|
67
|
+
[e67eff19-ae0e-4355-803a-c5577b6ba99a]
|
68
|
+
F, [2021-07-20T14:12:02.274062 #14195] FATAL -- : [5aa25c62-b307-4822-b719-9651c7270166]
|
69
|
+
[5aa25c62-b307-4822-b719-9651c7270166] ActionController::RoutingError (No route matches [GET] "/favicon.ico"):
|
70
|
+
[5aa25c62-b307-4822-b719-9651c7270166]
|
71
|
+
F, [2021-07-20T14:34:35.516776 #14195] FATAL -- : [78bae128-d8c7-4fc8-a4c0-455c85b64198]
|
72
|
+
[78bae128-d8c7-4fc8-a4c0-455c85b64198] ActionController::RoutingError (No route matches [GET] "/.env"):
|
73
|
+
[78bae128-d8c7-4fc8-a4c0-455c85b64198]
|
74
|
+
F, [2021-07-20T14:34:35.912826 #14195] FATAL -- : [a920c07c-d9f5-4e0a-9510-343fe65ba791]
|
75
|
+
[a920c07c-d9f5-4e0a-9510-343fe65ba791] ActionController::RoutingError (No route matches [POST] "/"):
|
30
76
|
|
77
|
+
config/environments/production.rb
|
78
|
+
Rails.application.configure do
|
79
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
80
|
+
|
81
|
+
# Code is not reloaded between requests.
|
82
|
+
config.cache_classes = true
|
31
83
|
|
32
|
-
```nginx
|
33
|
-
/etc/nginx/nginx.conf
|
34
|
-
|
84
|
+
config.eager_load = true
|
35
|
-
# * Official English Documentation: http://nginx.org/en/docs/
|
36
|
-
# * Official Russian Documentation: http://nginx.org/ru/docs/
|
37
85
|
|
38
|
-
user nginx;
|
39
|
-
worker_processes auto;
|
40
|
-
error_log /var/log/nginx/error.log;
|
41
|
-
pid /run/nginx.pid;
|
42
86
|
|
43
|
-
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
|
44
|
-
|
87
|
+
config.consider_all_requests_local = false
|
88
|
+
config.action_controller.perform_caching = true
|
45
89
|
|
46
|
-
events {
|
47
|
-
worker_connections 1024;
|
48
|
-
}
|
49
90
|
|
50
|
-
http {
|
51
|
-
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
52
|
-
|
91
|
+
config.require_master_key = true
|
53
|
-
'"$http_user_agent" "$http_x_forwarded_for"';
|
54
92
|
|
55
|
-
|
93
|
+
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
56
94
|
|
57
|
-
sendfile on;
|
58
|
-
tcp_nopush on;
|
59
|
-
tcp_nodelay on;
|
60
|
-
keepalive_timeout 65;
|
61
|
-
types_hash_max_size 4096;
|
62
|
-
client_max_body_size 20M;
|
63
|
-
include /etc/nginx/mime.types;
|
64
|
-
default_type application/octet-stream;
|
65
95
|
|
96
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
97
|
+
config.assets.compile = true
|
98
|
+
config.assets.initialize_on_precompile=false
|
99
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
66
|
-
|
100
|
+
# config.action_controller.asset_host = 'http://assets.example.com'
|
67
|
-
# See http://nginx.org/en/docs/ngx_core_module.html#include
|
68
|
-
# for more information.
|
69
|
-
include /etc/nginx/conf.d/*.conf;
|
70
101
|
|
71
|
-
server {
|
72
|
-
listen 80;
|
73
|
-
|
102
|
+
# Specifies the header that your server uses for sending files.
|
74
|
-
server_name _;
|
75
|
-
|
103
|
+
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
104
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
76
105
|
|
106
|
+
# Store uploaded files on the local file system (see config/storage.yml for options).
|
77
|
-
|
107
|
+
config.active_storage.service = :local
|
78
|
-
include /etc/nginx/default.d/*.conf;
|
79
108
|
|
80
|
-
|
109
|
+
# Mount Action Cable outside main process or domain.
|
81
|
-
|
110
|
+
# config.action_cable.mount_path = nil
|
82
|
-
|
111
|
+
# config.action_cable.url = 'wss://example.com/cable'
|
112
|
+
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http://example.*/ ]
|
83
113
|
|
84
|
-
|
114
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
85
|
-
|
115
|
+
# config.force_ssl = true
|
86
|
-
}
|
87
|
-
}
|
88
116
|
|
117
|
+
# Use the lowest log level to ensure availability of diagnostic information
|
118
|
+
# when problems arise.
|
119
|
+
config.log_level = :error
|
89
120
|
|
121
|
+
# Prepend all log lines with the following tags.
|
122
|
+
config.log_tags = [ :request_id ]
|
90
123
|
|
124
|
+
# Use a different cache store in production.
|
125
|
+
# config.cache_store = :mem_cache_store
|
126
|
+
|
127
|
+
# Use a real queuing backend for Active Job (and separate queues per environment).
|
128
|
+
# config.active_job.queue_adapter = :resque
|
129
|
+
# config.active_job.queue_name_prefix = "アプリ名_production"
|
130
|
+
|
131
|
+
config.action_mailer.perform_caching = false
|
132
|
+
|
133
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
134
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
135
|
+
# config.action_mailer.raise_delivery_errors = false
|
136
|
+
|
137
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
138
|
+
# the I18n.default_locale when a translation cannot be found).
|
139
|
+
config.i18n.fallbacks = true
|
140
|
+
|
141
|
+
# Send deprecation notices to registered listeners.
|
142
|
+
config.active_support.deprecation = :notify
|
143
|
+
|
144
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
145
|
+
config.log_formatter = ::Logger::Formatter.new
|
146
|
+
|
147
|
+
# Use a different logger for distributed setups.
|
148
|
+
# require 'syslog/logger'
|
149
|
+
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
150
|
+
|
151
|
+
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
152
|
+
logger = ActiveSupport::Logger.new(STDOUT)
|
153
|
+
logger.formatter = config.log_formatter
|
154
|
+
config.logger = Logger.new("log/production.log", 5, 10 * 1024 * 1024)
|
155
|
+
end
|
156
|
+
|
157
|
+
# Do not dump schema after migrations.
|
158
|
+
config.active_record.dump_schema_after_migration = false
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
config/puma.rb
|
165
|
+
|
166
|
+
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
|
167
|
+
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
|
168
|
+
threads min_threads_count, max_threads_count
|
169
|
+
|
170
|
+
#port ENV.fetch("PORT") { 3000 }
|
171
|
+
bind "unix://#{Rails.root}/tmp/sockets/puma.sock"
|
172
|
+
# Specifies the `environment` that Puma will run in.
|
173
|
+
#
|
174
|
+
environment ENV.fetch("RAILS_ENV") { "development" }
|
175
|
+
|
176
|
+
# Specifies the `pidfile` that Puma will use.
|
177
|
+
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
|
178
|
+
|
179
|
+
|
180
|
+
# Allow puma to be restarted by `rails restart` command.
|
181
|
+
plugin :tmp_restart
|
182
|
+
```
|
183
|
+
|
184
|
+
```nginx
|
185
|
+
|
91
186
|
/etc/nginx/conf.d/rails.conf
|
92
187
|
upstream puma {
|
93
188
|
# pumaの設定で指定したsocketファイルを指定
|
1
nginxのコード入れた
title
CHANGED
File without changes
|
body
CHANGED
@@ -23,163 +23,113 @@
|
|
23
23
|
rails server -e production
|
24
24
|
をした時は問題なくCSS・JSは表示される。
|
25
25
|
|
26
|
-
|
27
26
|
```
|
28
27
|
|
29
28
|
### 該当のソースコード
|
30
29
|
|
31
|
-
```ruby
|
32
|
-
log/production.log
|
33
|
-
[af1fe402-43d0-4797-900d-096e58574a44] ActionController::RoutingError (No route matches [GET] "/packs/media/slick/ajax-loader-c5cd7f53.gif"):
|
34
|
-
[af1fe402-43d0-4797-900d-096e58574a44]
|
35
|
-
F, [2021-07-20T13:53:30.078738 #14195] FATAL -- : [0eec3015-2980-4d50-88ea-dbdd38eee56e]
|
36
|
-
[0eec3015-2980-4d50-88ea-dbdd38eee56e] ActionController::RoutingError (No route matches [GET] "/packs/media/fonts/slick-d41f55a7.ttf"):
|
37
|
-
[0eec3015-2980-4d50-88ea-dbdd38eee56e]
|
38
|
-
F, [2021-07-20T13:53:36.578798 #14195] FATAL -- : [9170e9f1-6e53-4513-a842-5eb6b2a60fd6]
|
39
|
-
[9170e9f1-6e53-4513-a842-5eb6b2a60fd6] ActionController::RoutingError (No route matches [GET] "/packs/media/slick/ajax-loader-c5cd7f53.gif"):
|
40
|
-
[9170e9f1-6e53-4513-a842-5eb6b2a60fd6]
|
41
|
-
F, [2021-07-20T13:53:36.716955 #14195] FATAL -- : [45afdf57-8b00-43cf-93e7-b113b7a56154]
|
42
|
-
[45afdf57-8b00-43cf-93e7-b113b7a56154] ActionController::RoutingError (No route matches [GET] "/packs/media/fonts/slick-d41f55a7.ttf"):
|
43
|
-
[45afdf57-8b00-43cf-93e7-b113b7a56154]
|
44
|
-
F, [2021-07-20T13:54:02.049332 #14195] FATAL -- : [ce1c4b7b-19e1-46e3-b1a6-f73dac82ec46]
|
45
|
-
[ce1c4b7b-19e1-46e3-b1a6-f73dac82ec46] ActionController::RoutingError (No route matches [GET] "/packs/js/application-b610d75862aa1fd2e383.js.map"):
|
46
|
-
[ce1c4b7b-19e1-46e3-b1a6-f73dac82ec46]
|
47
|
-
F, [2021-07-20T13:54:02.207922 #14195] FATAL -- : [713e50a8-f7b5-4cf9-b21f-dafc41e19fb2]
|
48
|
-
[713e50a8-f7b5-4cf9-b21f-dafc41e19fb2] ActionController::RoutingError (No route matches [GET] "/packs/media/slick/ajax-loader-c5cd7f53.gif"):
|
49
|
-
[713e50a8-f7b5-4cf9-b21f-dafc41e19fb2]
|
50
|
-
F, [2021-07-20T13:54:02.267868 #14195] FATAL -- : [ff052d0f-281e-489c-bd80-5d30bb6e8115]
|
51
|
-
[ff052d0f-281e-489c-bd80-5d30bb6e8115] ActionController::RoutingError (No route matches [GET] "/packs/media/fonts/slick-b7c9e1e4.woff"):
|
52
|
-
[ff052d0f-281e-489c-bd80-5d30bb6e8115]
|
53
|
-
F, [2021-07-20T13:54:02.338087 #14195] FATAL -- : [303e39fa-3183-46f7-80fa-2e371385ad18]
|
54
|
-
[303e39fa-3183-46f7-80fa-2e371385ad18] ActionController::RoutingError (No route matches [GET] "/packs/media/fonts/slick-d41f55a7.ttf"):
|
55
|
-
[303e39fa-3183-46f7-80fa-2e371385ad18]
|
56
|
-
F, [2021-07-20T13:54:06.528087 #14195] FATAL -- : [1c41adf1-a49d-46e9-b945-91f5bbc3a596]
|
57
|
-
[1c41adf1-a49d-46e9-b945-91f5bbc3a596] ActionController::RoutingError (No route matches [GET] "/packs/js/application-b610d75862aa1fd2e383.js.map"):
|
58
|
-
[1c41adf1-a49d-46e9-b945-91f5bbc3a596]
|
59
|
-
F, [2021-07-20T13:54:06.725809 #14195] FATAL -- : [c52df05e-c1f8-4e3e-af2b-f19bd1197ab6]
|
60
|
-
[c52df05e-c1f8-4e3e-af2b-f19bd1197ab6] ActionController::RoutingError (No route matches [GET] "/packs/media/slick/ajax-loader-c5cd7f53.gif"):
|
61
|
-
[c52df05e-c1f8-4e3e-af2b-f19bd1197ab6]
|
62
|
-
F, [2021-07-20T13:54:06.778260 #14195] FATAL -- : [c5580b05-6b49-4be0-8e3f-4c2614a11b98]
|
63
|
-
[c5580b05-6b49-4be0-8e3f-4c2614a11b98] ActionController::RoutingError (No route matches [GET] "/packs/media/fonts/slick-b7c9e1e4.woff"):
|
64
|
-
[c5580b05-6b49-4be0-8e3f-4c2614a11b98]
|
65
|
-
F, [2021-07-20T13:54:06.934064 #14195] FATAL -- : [e67eff19-ae0e-4355-803a-c5577b6ba99a]
|
66
|
-
[e67eff19-ae0e-4355-803a-c5577b6ba99a] ActionController::RoutingError (No route matches [GET] "/packs/media/fonts/slick-d41f55a7.ttf"):
|
67
|
-
[e67eff19-ae0e-4355-803a-c5577b6ba99a]
|
68
|
-
F, [2021-07-20T14:12:02.274062 #14195] FATAL -- : [5aa25c62-b307-4822-b719-9651c7270166]
|
69
|
-
[5aa25c62-b307-4822-b719-9651c7270166] ActionController::RoutingError (No route matches [GET] "/favicon.ico"):
|
70
|
-
[5aa25c62-b307-4822-b719-9651c7270166]
|
71
|
-
F, [2021-07-20T14:34:35.516776 #14195] FATAL -- : [78bae128-d8c7-4fc8-a4c0-455c85b64198]
|
72
|
-
[78bae128-d8c7-4fc8-a4c0-455c85b64198] ActionController::RoutingError (No route matches [GET] "/.env"):
|
73
|
-
[78bae128-d8c7-4fc8-a4c0-455c85b64198]
|
74
|
-
F, [2021-07-20T14:34:35.912826 #14195] FATAL -- : [a920c07c-d9f5-4e0a-9510-343fe65ba791]
|
75
|
-
[a920c07c-d9f5-4e0a-9510-343fe65ba791] ActionController::RoutingError (No route matches [POST] "/"):
|
76
30
|
|
77
|
-
config/environments/production.rb
|
78
|
-
Rails.application.configure do
|
79
|
-
# Settings specified here will take precedence over those in config/application.rb.
|
80
|
-
|
81
|
-
# Code is not reloaded between requests.
|
82
|
-
config.cache_classes = true
|
83
31
|
|
32
|
+
```nginx
|
33
|
+
/etc/nginx/nginx.conf
|
84
|
-
|
34
|
+
# For more information on configuration, see:
|
35
|
+
# * Official English Documentation: http://nginx.org/en/docs/
|
36
|
+
# * Official Russian Documentation: http://nginx.org/ru/docs/
|
85
37
|
|
38
|
+
user nginx;
|
39
|
+
worker_processes auto;
|
40
|
+
error_log /var/log/nginx/error.log;
|
41
|
+
pid /run/nginx.pid;
|
86
42
|
|
43
|
+
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
|
87
|
-
|
44
|
+
include /usr/share/nginx/modules/*.conf;
|
88
|
-
config.action_controller.perform_caching = true
|
89
45
|
|
46
|
+
events {
|
47
|
+
worker_connections 1024;
|
48
|
+
}
|
90
49
|
|
50
|
+
http {
|
51
|
+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
91
|
-
|
52
|
+
'$status $body_bytes_sent "$http_referer" '
|
53
|
+
'"$http_user_agent" "$http_x_forwarded_for"';
|
92
54
|
|
93
|
-
|
55
|
+
access_log /var/log/nginx/access.log main;
|
94
56
|
|
57
|
+
sendfile on;
|
58
|
+
tcp_nopush on;
|
59
|
+
tcp_nodelay on;
|
60
|
+
keepalive_timeout 65;
|
61
|
+
types_hash_max_size 4096;
|
62
|
+
client_max_body_size 20M;
|
63
|
+
include /etc/nginx/mime.types;
|
64
|
+
default_type application/octet-stream;
|
95
65
|
|
96
|
-
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
97
|
-
config.assets.compile = true
|
98
|
-
config.assets.initialize_on_precompile=false
|
99
|
-
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
100
|
-
|
66
|
+
# Load modular configuration files from the /etc/nginx/conf.d directory.
|
67
|
+
# See http://nginx.org/en/docs/ngx_core_module.html#include
|
68
|
+
# for more information.
|
69
|
+
include /etc/nginx/conf.d/*.conf;
|
101
70
|
|
71
|
+
server {
|
72
|
+
listen 80;
|
102
|
-
|
73
|
+
listen [::]:80;
|
74
|
+
server_name _;
|
103
|
-
|
75
|
+
root /usr/share/nginx/html;
|
104
|
-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
105
76
|
|
106
|
-
# Store uploaded files on the local file system (see config/storage.yml for options).
|
107
|
-
|
77
|
+
# Load configuration files for the default server block.
|
78
|
+
include /etc/nginx/default.d/*.conf;
|
108
79
|
|
109
|
-
|
80
|
+
error_page 404 /404.html;
|
110
|
-
|
81
|
+
location = /404.html {
|
111
|
-
|
82
|
+
}
|
112
|
-
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http://example.*/ ]
|
113
83
|
|
114
|
-
|
84
|
+
error_page 500 502 503 504 /50x.html;
|
115
|
-
|
85
|
+
location = /50x.html {
|
86
|
+
}
|
87
|
+
}
|
116
88
|
|
117
|
-
# Use the lowest log level to ensure availability of diagnostic information
|
118
|
-
# when problems arise.
|
119
|
-
config.log_level = :error
|
120
89
|
|
121
|
-
# Prepend all log lines with the following tags.
|
122
|
-
config.log_tags = [ :request_id ]
|
123
90
|
|
124
|
-
|
91
|
+
/etc/nginx/conf.d/rails.conf
|
92
|
+
upstream puma {
|
125
|
-
|
93
|
+
# pumaの設定で指定したsocketファイルを指定
|
126
94
|
|
127
|
-
# Use a real queuing backend for Active Job (and separate queues per environment).
|
128
|
-
# config.active_job.queue_adapter = :resque
|
129
|
-
|
95
|
+
server unix:///var//www/アプリ名/tmp/sockets/puma.sock;
|
130
96
|
|
131
|
-
|
97
|
+
}
|
132
98
|
|
133
|
-
|
99
|
+
server {
|
134
|
-
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
135
|
-
|
100
|
+
# nginxが待ち受けしたいポートを指定
|
136
101
|
|
137
|
-
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
138
|
-
# the I18n.default_locale when a translation cannot be found).
|
139
|
-
|
102
|
+
listen 3000 default_server;
|
140
103
|
|
141
|
-
|
104
|
+
listen [::]:3000 default_server;
|
142
|
-
config.active_support.deprecation = :notify
|
143
105
|
|
144
|
-
# Use default logging formatter so that PID and timestamp are not suppressed.
|
145
|
-
|
106
|
+
server_name puma;
|
146
107
|
|
147
|
-
|
108
|
+
location ~* .(html|scss|js)$ {
|
148
|
-
|
109
|
+
root /var/www/アプリ名/public;
|
110
|
+
expires 10d;
|
149
|
-
|
111
|
+
access_log off;
|
112
|
+
break;
|
113
|
+
}
|
150
114
|
|
151
|
-
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
152
|
-
|
115
|
+
location / {
|
153
|
-
|
116
|
+
proxy_read_timeout 300;
|
154
|
-
config.logger = Logger.new("log/production.log", 5, 10 * 1024 * 1024)
|
155
|
-
end
|
156
117
|
|
157
|
-
|
118
|
+
proxy_connect_timeout 300;
|
158
|
-
config.active_record.dump_schema_after_migration = false
|
159
119
|
|
120
|
+
proxy_redirect off;
|
160
121
|
|
122
|
+
proxy_set_header Host $host;
|
161
123
|
|
162
|
-
|
124
|
+
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
|
163
125
|
|
164
|
-
|
126
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
165
127
|
|
166
|
-
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
|
167
|
-
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
|
168
|
-
|
128
|
+
# 上記server_name で設定した名前で指定
|
169
129
|
|
170
|
-
#port ENV.fetch("PORT") { 3000 }
|
171
|
-
bind "unix://#{Rails.root}/tmp/sockets/puma.sock"
|
172
|
-
# Specifies the `environment` that Puma will run in.
|
173
|
-
#
|
174
|
-
environment ENV.fetch("RAILS_ENV") { "development" }
|
175
|
-
|
176
|
-
|
130
|
+
proxy_pass http://puma;
|
177
|
-
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
|
178
|
-
|
179
|
-
|
180
|
-
# Allow puma to be restarted by `rails restart` command.
|
181
|
-
|
131
|
+
}
|
182
|
-
|
132
|
+
}
|
183
133
|
```
|
184
134
|
|
185
135
|
### 試したこと
|