質問編集履歴

1

ためしてみた

2021/05/05 08:53

投稿

yaha4967
yaha4967

スコア106

test CHANGED
File without changes
test CHANGED
@@ -14,9 +14,21 @@
14
14
 
15
15
 
16
16
 
17
+ Rails
18
+
17
- Railsのアプリ名PuAReview
19
+ アプリ名:PuAReview
20
+
18
-
21
+ ルート:(ドメイン)/api/v1~
22
+
23
+
24
+
25
+ React
26
+
19
- Reactのアプリ名frontendです。
27
+ アプリ名:frontend
28
+
29
+ ルート:(ドメイン)/~
30
+
31
+
20
32
 
21
33
 
22
34
 
@@ -367,3 +379,125 @@
367
379
 
368
380
 
369
381
  どこが間違っているか分かる方いらっしゃいましたらヒント教えていただきたいです。よろしくお願いします。
382
+
383
+
384
+
385
+ ### 追記
386
+
387
+ rootの設定してみました!
388
+
389
+ 結論からいうとrootつけてみましたが、変化なしでした。。。
390
+
391
+ ### 試したこと
392
+
393
+
394
+
395
+ /etc/nginx/conf.d
396
+
397
+
398
+
399
+ にfrontend.confを追加
400
+
401
+
402
+
403
+ frontend.conf
404
+
405
+
406
+
407
+ ```ここに言語を入力
408
+
409
+ server {
410
+
411
+ listen 80;
412
+
413
+ server_name 52.193.23.14;
414
+
415
+ index index.html;
416
+
417
+ access_log /var/log/nginx/frontend.access.log;
418
+
419
+ error_log /var/log/nginx/frontend.error.log;
420
+
421
+ location / {
422
+
423
+ root /var/www/PuAReview/frontend/build;
424
+
425
+ try_files $uri /index.html =404;
426
+
427
+ }
428
+
429
+ }
430
+
431
+ ```
432
+
433
+
434
+
435
+ このままだとserver name conflictしてしまうので、PuAReview.confのlistenを81に変更。
436
+
437
+ あと、location 〇〇{}の意味が〇〇のURLにアクセスしたとき{}内のファイルにアクセスするという意味ぽいのでこう書いてみました。
438
+
439
+
440
+
441
+ ```
442
+
443
+ server {
444
+
445
+ listen 81;
446
+
447
+ server_name 52.193.23.14;
448
+
449
+ # nginx so increasing this is generally safe...
450
+
451
+ keepalive_timeout 5;
452
+
453
+ # path for static files
454
+
455
+ #root /var/www/PuAReview/frontend/build; #added
456
+
457
+ location /api/v1{
458
+
459
+ root /var/www/PuAReview/public;
460
+
461
+ }
462
+
463
+
464
+
465
+ #root /var/www/PuAReview/frontend/build;
466
+
467
+
468
+
469
+ # page cache loading
470
+
471
+ try_files $uri /index.html;
472
+
473
+ location @app {
474
+
475
+ # HTTP headers
476
+
477
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
478
+
479
+ proxy_set_header Host $http_host;
480
+
481
+ proxy_redirect off;
482
+
483
+ proxy_pass http://app_server;
484
+
485
+
486
+
487
+
488
+
489
+ }
490
+
491
+ # Rails error pages
492
+
493
+ error_page 500 502 503 504 /500.html;
494
+
495
+ location = /500.html {
496
+
497
+ root /var/www/PuAReview/public; #自分のアプリケーション名に変
498
+
499
+ }
500
+
501
+ }
502
+
503
+ ```