Nginx

How to set up SSL with nginx

I'm using Comodo PositiveSSL service inside Namecheap website.

So, first we need to activate PositiveSSL online, just following the instructions given by Namecheap.

To do that, you will need a .csr file. It's a certificate signing request (CSR).

To generate .csr file:

$ openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr

Then, PositiveSSL will give us a .zip file containing yourdomain.csr, yourdomain.ca-bundle, and yourdomain.p7b. We concatenate yourdomain.ca-bundle to yourdomain.csr to get a new file called ssl-bundle.csr. Hence, this file contains all the certificate information from our side to the root CA side.

After that, we can follow https://support.comodo.com/index.php?/Knowledgebase/Article/View/1091/0/certificate-installation--nginx

Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response.

Also, If your server is Node.js, you should add location / { proxy_pass http://localhost:3000; } to the https server block. proxy_pass simply tells Nginx to forward requests to / to the server listening on http://localhost:3000.

Last updated