I followed the steps Sammy the shark showed me regarding the “Get your code on here” section of the default landing page
- Launch your app by calling
pm2 start <your-file>
, then map the port your app runs on to an HTTP URL by runningnano /etc/nginx/sites-available/default
and adding anotherlocation
. Use the existing entry for the port 3000 “hello” app as a basis.
sudo systemctl restart nginx
to enable your new nginx config.pm2 save
to schedule your code to run at launch.I expected to at least see an error message because I moved the “hello.js” and “index.nginx-debian.html” files into another directory but I still see the “Sammy welcomes you to your droplet” page when I visit my domain.
here is what my /var/www/html/archive directory looks like (where I moved the old files)
and here is what’s in my /var/www/html/ directory (populated with my react app build files)
and this is my default “sites-available” file. I left it unchanged since I didn’t need to change the destination it was pointing to
I’m very new at this and I’m learning a lot about how a website is hosted and served. But I’m not sure if I did something wrong or if I missed a step.
How is my domain still loading the default digitalocean landing page when I moved it to another directory? and why are my new react app build’s index.html file not being detected?
(my droplet is running Node JS on Ubuntu 20.04)
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hey there 👋
Quick check, are you trying to serve a React static site or are you running a full Node.js backend too?
If it’s just a React frontend (like after
npm run build
), you don’t need PM2 or a Node process running. You can just let Nginx serve the static files directly from/var/www/html
. Running the React dev server in production is not recommended.Make sure your Nginx config has something like:
Then restart Nginx:
If you’re using a Node backend (like Express or Vite SSR), that’s when PM2 and the
proxy_pass
setup to port 3000 makes sense.Let me know how it goes!
- Bobby