-1

I developed a MEAN app and got ready to host it. As a production hosting environment I chose Digital Ocean. For deployment I did the below:

1. Started up a droplet with Ubuntu 
2. Got ready-to-use MEAN image on it.
3. copied my application from local machine onto this droplet (using flightplan)
So far so good.. everything works fine.

However, I need to serve the application using https, hence I need a digital certificate.

On searching around, I read threads which said, install NGinx and then install the digital certificate. There are a bunch of threads which i am finding it difficult to follow. This is mainly because I have very cursory understanding of this new stack.

At this point I am wondering, my express http server is already serving static files.

Now what will be the role of nginx in this whole equation? how do i route traffic from nginx to express application or vice versa. Do I really need to do this ? Is there no way to install a digital certificate with node ??

At the end of the day, I need to serve traffic over https.

I would like to achieve this without much complication in my stack.

Any advice ?

runtimeZero
  • 26,466
  • 27
  • 73
  • 126
  • Your node server will run on some other port, not 80/443, for example, port 3000. nginx will listen for requests on 80 and 433, and redirect requests from 80 to 443. It will then reverse proxy all requests from 433 to localhost:3000, and your node server can then handle the request not caring about ssl. – Kevin B Sep 28 '15 at 21:35
  • This answer might be helpful for you: http://stackoverflow.com/a/16770780/400654 the one below it too. – Kevin B Sep 28 '15 at 21:50

1 Answers1

1

You can get ssl certificates from a paid dns provider or can get dummy ssl certificates using some utilities like letsencrypt.

The nginx will then listen on 443 port and you can configure nginx to pass the request to the node application which may not require ssl certificate. Lets say your node is running on 3000. Nginx will pass the request to this port.

This link will tell how to do that ===> https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-14-04

Advay Umare
  • 432
  • 10
  • 23