0

I put the files of my React build in: root/website.com/site/public.

My /etc/nginx/sites-available/default:

server {
    listen 80 default_server;
    root /root/website.com/site/public/;
    server_name 00.000.00.000; 
    index index.html index.htm;
    location / {
            try_files $uri $uri/ =404;
    }
}

I get a bad gateway error when I go to my ip address. Do I need to run npm start to get my index.html to show up?

For some reason when I run npm start it searches for index.html in /site/src then if I change the name of public to src it searches in site/public.

johnboy
  • 111
  • 1
  • 6
  • try to use the root directory of your application if that may help. I got the idea from this. https://codeburst.io/how-to-setup-nginx-for-react-a504f38f95ed or at least the react app is built based on this https://medium.com/@timmykko/deploying-create-react-app-with-nginx-and-ubuntu-e6fe83c5e9e7 edit: found a similar question here and there's an answer :D hope this helps https://stackoverflow.com/questions/46880853/deploy-create-react-app-on-nginx – Don F. May 09 '20 at 19:53
  • 1
    Thanks for your answer. That did not work for me though. – johnboy May 09 '20 at 19:58
  • 1
    https://stackoverflow.com/questions/46880853/deploy-create-react-app-on-nginx found this :) please try this out :D and check your permissions as well :) – Don F. May 09 '20 at 20:01
  • 1
    Thanks for your help! I will try these and post if anything works for me. – johnboy May 09 '20 at 20:14

1 Answers1

0

Using /root/website.com/site/public was unreachable by nginx apparently. Changed it to the typical /var/www/website/site/public and moved my build file there and it worked.

johnboy
  • 111
  • 1
  • 6