Do I need to set nginx and proxy or there is a better way to directly running build without giving :3000?
The Node http server takes a lot of effort to do what classic web servers like nginx/...
For example: request queuing. There are no restrictions in Node. It opens new connections
until the server use all resources. Also I have experienced problems with keep-alive
header.
And HTTPS should be provided...
Of course, this can be handled directly in Node.
And CORS. And some deny IPs. And some rate-limiting for IP...
You can reinvent the wheel, and you can use best practices from the web server. BTW: remember that Node is single-threaded and Node's handling of it is inefficient.
- Keep your app running in background.
- Serve static files outside node.
Because the web server is better at it. Thanks to this, you can get a few percent increase in performance.
Yes, You must have something that will start your application after server restart. Or restart app after fatal-error. You can:
- create systemd service
- use some node manager like:
pm2
orfotrever
(Is it still maintained?) - I'm prefer Passenger
- Buy
- https://letsencrypt.org/
- Caddy
- Full secure your service by Cloudflare. (DDOS protection + CDN + WAF + SSL + ...)