Configure Nginx to use your SSL certificate
Create a folder to store the SSL certificates inside the Nginx configuration using the following command.
# sudo mkdir /etc/nginx/ssl
Then copy the certificate
and the private key
to this location. Please rename the files to show which domain they are associated with.
# sudo cp /path/to/your/certificate.crt /etc/nginx/ssl/example.com.crt
# sudo cp /path/to/your/private.key /etc/nginx/ssl/example.com.key
Then you need to open the configuration file and update the configure SSL details.
# nano /etc/nginx/sites-available/default
or
# vi /etc/nginx/sites-available/default
Add the SSL configure details inside the server block, define the location of your certificates and Save the file and exit.
ssl_certificate /etc/nginx/ssl/example.com.crt;
ssl_certificate_key /etc/nginx/ssl/example.com.key;
NOTE: Replace the example.com
with the actual domain name. Here we use self-signed SSL for the same.