teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

Nginxの設定を追記

2019/10/19 08:02

投稿

jooooz_jjj
jooooz_jjj

スコア4

title CHANGED
File without changes
body CHANGED
@@ -153,6 +153,7 @@
153
153
 
154
154
  と表示されました。
155
155
 
156
+
156
157
  #nginx再起動
157
158
  sudo service nginx restart
158
159
 
@@ -160,6 +161,97 @@
160
161
  正常にサイトにアクセスできない問題が解決しないために、
161
162
  編集前の状態に戻しています。
162
163
 
164
+ #Nginxの状態追記
165
+
166
+
167
+ upstream puma {
168
+
169
+ server unix:///home/ec2-user/first_portfolio/tmp/sockets/puma.sock;
170
+
171
+ }
172
+
173
+ server {
174
+
175
+ server_name melhealhabit.com;
176
+
177
+ root /home/ec2-user/first_portfolio/public;
178
+
179
+
180
+ access_log /var/log/nginx/access.log main;
181
+
182
+ error_log /var/log/nginx/error.log;
183
+
184
+ sendfile on;
185
+
186
+   tcp_nopush on;
187
+
188
+ tcp_nodelay on;
189
+
190
+ keepalive_timeout 65;
191
+
192
+
193
+ types_hash_max_size 2048;
194
+
195
+ include /etc/nginx/mime.types;
196
+
197
+ location / {
198
+
199
+ proxy_pass http://puma;
200
+
201
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
202
+
203
+ proxy_set_header Host $http_host;
204
+
205
+      proxy_set_header X-Real-IP $remote_addr;
206
+
207
+ proxy_redirect off;
208
+
209
+ proxy_connect_timeout 30;
210
+
211
+
212
+ }
213
+
214
+
215
+ error_page 500 502 503 504 /50x.html;
216
+
217
+
218
+ location = /50x.html {
219
+
220
+ root /home/ec2-user/first_portfolio/public;
221
+
222
+ }
223
+
224
+ listen 443 ssl; # managed by Certbot
225
+ ssl_certificate /etc/letsencrypt/live/melhealhabit.com/fullchain.pem; # managed by Certbot
226
+ ssl_certificate_key /etc/letsencrypt/live/melhealhabit.com/privkey.pem; # managed by Certbot
227
+ include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
228
+ ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
229
+
230
+
231
+ }
232
+
233
+ server {
234
+ if ($host = melhealhabit.com) {
235
+ return 301 https://$host$request_uri;
236
+ } # managed by Certbot
237
+
238
+
239
+
240
+ listen 80;
241
+
242
+ server_name melhealhabit.com;
243
+ return 404; # managed by Certbot
244
+
245
+ }
246
+
247
+
248
+
249
+
250
+
251
+      
252
+
253
+
254
+
163
255
  ### 補足情報(FW/ツールのバージョンなど)
164
256
 
165
257
   IPアドレスを直接ブラウザに打ち込むとnginxへようこそのページに遷移します。