How do I serve my index.html file with Node.js on Ubuntu?

0
3
Asked By CreativePineapple92 On

I've just set up Node.js on my Ubuntu server for the first time. I also have a domain name through Cloudflare, and I use Nginx Proxy Manager to access everything online when I'm away from home. I'm trying to view my index.html page located in a folder on my server, which also contains a package.json file and some backend code for Stripe payment integration. However, when I try to access my page, all I see is a status response, but no actual webpage content. I believe I might be missing something important in serving the HTML file along with my Stripe backend. I configured Nginx with the appropriate root and index settings but it's still not displaying the content as expected.

1 Answer

Answered By SillyWombat456 On

It sounds like you have the reverse proxy setup to the internet via port 443, which is great! What you need is a way to connect your Node.js app to that proxy. You can use a process manager like PM2 or even Docker to handle your web app instances. This allows you to keep the server running and automatically restart it after updates. Your Node.js app should listen on a specific port (like 3000), and the proxy will forward requests to that port. If you're using PM2, it’s simple to access your running instances through its command line. Just run `pm2 list` to see what's active. Let me know if you want more details about using PM2!

CuriousFox123 -

Got it, I already did set PM2 up and I’m listening on port 3000. Can we dive deeper into how to manage those processes? I really just want to show my index.html page and connect it with the backend code I have for Stripe, especially since this is all being tested on a subdomain.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.