skip to Main Content

I am having issues running my react app on nginx which i am running on AWS EC2 instance.
My files paths for index.html is in build:

`-rw-rw-r-- 1 ubuntu ubuntu 1353 Sep 23 08:52 asset-manifest.json
-rw-rw-r-- 1 ubuntu ubuntu 3870 Sep 23 08:52 favicon.ico
-rw-rw-r-- 1 ubuntu ubuntu 3212 Sep 23 08:52 index.html
-rw-rw-r-- 1 ubuntu ubuntu 5347 Sep 23 08:52 logo192.png
-rw-rw-r-- 1 ubuntu ubuntu 9664 Sep 23 08:52 logo512.png
-rw-rw-r-- 1 ubuntu ubuntu  492 Sep 23 08:52 manifest.json
-rw-rw-r-- 1 ubuntu ubuntu 1231 Sep 23 08:52 precache-manifest.7e468f7af076de91adb94c7c9a531eff.js
-rw-rw-r-- 1 ubuntu ubuntu   67 Sep 23 08:52 robots.txt
-rw-rw-r-- 1 ubuntu ubuntu 1039 Sep 23 08:52 service-worker.js
drwxrwxr-x 5 ubuntu ubuntu 4096 Sep 23 08:52 static
ubuntu:~/Desktop/Restaurant_App/front-end/build$ pwd
/home/ubuntu/Desktop/Restaurant_App/front-end/build `

I added react.conf file in the following way :

`server {
    listen 80;
    listen [::]:80;
    root /home/ubantu/Desktop/Restaurant-App/front-end/build;
    location / {
    try_files $uri /home/ubantu/Desktop/app-deploy/public/index.html;
    }
}`

This is not working, it is not displaying the actual page and shoing standard nginx page. I have spent 4 days on this and no video or chatgpt is helping in this so far.

I have changed the server multiple time but it does not work at all.

2

Answers


  1. You misspelled the path (ubantu vs ubuntu):

    Change:

    server {
        listen 80;
        listen [::]:80;
        root /home/ubantu/Desktop/Restaurant-App/front-end/build;
        location / {
        try_files $uri /home/ubantu/Desktop/app-deploy/public/index.html;
        }
    }
    

    To:

    server {
        listen 80;
        listen [::]:80;
        root /home/ubuntu/Desktop/Restaurant-App/front-end/build;
        location / {
        try_files $uri /home/ubuntu/Desktop/app-deploy/public/index.html;
        }
    }
    
    Login or Signup to reply.
  2. Try this

    server {
        listen 80;
        listen [::]:80;
        root /home/ubuntu/Desktop/Restaurant_App/front-end/build;
        location / {
        try_files $uri $uri/index.html index.html;
        }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search