By johnstephens
Hi! I followed the instructions here, https://www.digitalocean.com/community/articles/how-to-install-node-js-with-nvm-node-version-manager-on-a-vps, and I got a Node app up and running on port 3000. When I direct requests to that port, I see my app, but not when I send a request without specifying a port.
I tried running $ PORT=80 node app, and Node threw an error and quit. It worked when I used PORT=8080 though.
On IRC, @kamal_ suggested I install and configure NGINX to to serve the static files “and pass everything else to Node.js”, and now I have NGINX up and running. When I go to my droplet’s IP now, I see “Welcome to nginx!” instead of having the connection refused, but I still have to append :3000 to the URL to see my Node app.
This is the NGINX config file I got from @kamal_: https://p.kk7.me/mepayofuqo.nginx
What are the next steps to making the app load on requests to the default port?
Thanks in advance!
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!
You can use the proxy
server_name example.com;
access_log /var/log/nginx/your.log;
location / {
proxy_pass http://127.0.0.1:3000/;
}
Launching the app with sudo works fine. There’s probably security implications. I’m not a backend guy. But it will work for now.
Edit: No, it’s not… I give up.
Thanks for this ressources! Check this course it’s straight to point and it gives you all the keys to a good start for a complete masteration of node.js by taking all the power of it. https://www.udemy.com/nodejs-tutorial-from-scratch-by-examples/
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.