Nginx - Install a SSL certificate

This article explains how to install an SSL certificate on Nginx (and Nginx+). The article assumes that you have already generated a private key and received your public certificate.







1 - Create a certificate chain

Certificate providers will provide two files upon issuing a new certificate:

  • The actual certificate. E.g.: mydomain.com.crt
  • The provider bundle certificate: E.g.: gd_bundle-g2-g1.crt

To install your certificate on Nginx you will need to concatenate these two certificates.

cat mydomain.com.crt bundle.crt > mydomain.com.chained.crt
 
# E.g.: maestrano.io wildcard certificate issued by GoDaddy
# cat maestrano.io.wildcard.crt gd_bundle-g2-g1.crt > maestrano.io.wildcard.chained.crt


2 - Install the certificate on Nginx

Here are the steps to add a certificate on Nginx:

  1. Upload your chained certificate (mydomain.com.chained.crt) and certificate key (mydomain.com.key) to your server
  2. Drop the files in a logical location. E.g.: /etc/nginx/certificates/mydomain.com-2015/
  3. Edit your Nginx location to look like the following:

    server {
      server_name  mydomain.com;
      listen       443;
     
      ssl on;
      ssl_certificate /etc/nginx/certificates/mydomain.com-2015/mydomain.com.chained.crt;
      ssl_certificate_key /etc/nginx/certificates/mydomain.com-2015/mydomain.com.key;
      
      ...
    }
  4. Finally, reload Nginx:

    service nginx reload