Report this

What is the reason for this report?

Deploy my Node App served from my Droplet

Posted on June 18, 2017
MLR

By MLR

Hello, I followed DigitalOcean’s (DO) instructions to deploy a simple “Hello World” app. Please keep in mind:

  1. I got it to work in my DO droplet (I see the rendered content: mydomain.com/my-app/).
  2. I understand it’s server.js code.
  3. I understand it’s sites_available >default code.
  4. I see another DO Community member asked this question, but there’s not solution.
  5. I want my node app to be served from my droplet. Not another service like: http://my-app.dokku.me, or Hreoku The DO “Hello World” app (server.js) only renders text content. I want to use this script (server.js) to start my index.html of my Node app. Side note: my index.html contains links to app.bundle.js, app.css & an image folder. What code do I change/use (in the code, below) to start my Node (Webpack) app ?
http.createServer(function(request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World on port 3001');
}).listen(3001, '999.999.99.999');```
Note: I've spent over 25 hours on this one aspect. 
    I've exhausted all resources I can think of. YouTube, DO, Google, ... 
Thank-you, Michael Rooney 


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.

@MLR Starting a new thread, since it got too narrow.

  1. Find a small app and use that as your template. You need to have routes, and usually a folder called public where you place those things. But again, this goes into waaayyy too much coding, so I would probably recommend that you ask in a Node forum like StackOverflow: https://stackoverflow.com/questions/tagged/node.js

  2. localhost is an alias of the IP 127.0.0.1. The 999-IP, well I’m guessing that’s your masked public IP, is still “owned” by the server, but that means Node is publicly available on port 3001 (if the firewall is open). Using 127.0.0.1 means that it’s only services on the server that can see those - and that’s what we want, because we want Nginx to see Node and serve the data to visitors.

This comment has been deleted

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.