Loading ...
Try HTTPCS +33 1 85 09 15 09

How to install an SSL certificate on Nginx

On 03/07/2018 By Valentin Ricci

Pre-requirement

You need :
To have already generated the CSR request, you can do it on our website.

To have saved the private key you obtained when you've generated the CSR, it will be needed in this tutorial.

A root access on the server.

To have already installed OpenSSL. How to install an SSL certificate on Nginx

To wait for the certificate authority to validate the CSR. When it is validated, you can download the certificate on your HTTPCS account, in « My SSL Certificates » category and click on « Download ».

How to install an SSL certificate on Nginx



Step by step tutorial to install SSL certificate on Nginx

NB : All the following commands have to be executed with root privileges.

1. Create a directory named « ssl » in Nginx's directory (if it does not already exist).
How to install an SSL certificate on Nginx

2. Extract the archive you just downloaded from your HTTPCS account and copy the files to the directory you had just created. How to install an SSL certificate on Nginx

NB : Replace « deb8user » by your username.

3. Concatenate these 3 files into one named CABundle.cer, using the following command.
How to install an SSL certificate on Nginx

NB : Your « CABundle.cer » file should look like this :
How to install an SSL certificate on Nginx

4. Go to the « sites-available » folder in the Nginx's directory. How to install an SSL certificate on Nginx

5. Find the VirtualHost configuration file, which is named « your_domain_name » (in this example, you’ll see « example »). How to install an SSL certificate on Nginx

6. Open your VirtualHost configuration file with your favorite text editor. How to install an SSL certificate on Nginx

Be careful, this file is case sensitive !

NB : To make it easier to read, I have removed all comments but it’s not recommended.

NB : This file is a minimal configuration for SSL website, used to illustrate this tutorial. It is really important to properly configure your Nginx server for better performance and security.

7. Make sure the listening port is set to 443.
« server_name » : your domain name
« ssl on » : enables SSL module
« ssl_certificate » : Indicates the path to your « CABundle.cer » file (the one you've just created with the "cat" command).
« ssl_certificate_key » : Indicates the path to your private key file (the file you obtained when you've generated the CSR).

8. Test your Nginx configuration to make sure your configuration file's syntax is valid typing the following command.
How to install an SSL certificate on Nginx

9. If everything's ok, you can restart your Nginx server typing How to install an SSL certificate on Nginx

10. You can now test your SSL certificate.

Buy cheap SSL certificates for Nginx

HTTPCS desktop screenshot Scanner HTTPCS tablet screenshot Scanner HTTPCS phone screenshot Scanner