First of all, Generate SSL certificate easily with WP Encryption WordPress plugin, then follow the below steps to install them on your Nginx server:
1. Login to your SSH console
If you have Nginx server running on cloud platforms like AWS or Digital Ocean, you might be able to login via SSH using Launch Console option. Otherwise, you can login using SSH key file or password via terminal.
2. Upload SSL certificates to secure folder and merge certs
Download crt, key & ca bundle files via WP Encryption plugin interface, rename them as certificate.crt, private.pem, cabundle.crt accordingly for easier identification and upload them onto a secure folder of your choice. Let’s assume you uploaded them to /etc/ssl/ directory.
cd /etc/ssl/ and merge certificate.crt and cabundle.crt files using below SSH command
cat certificate.crt cabundle.crt >> cert.crt
3. Update Nginx virtual host with correct SSL paths
cd /etc/nginx/sites-enabled/ directory and modify the default file using nano editor. If you don’t find any file here, copy the default file from /etc/nginx/sites-available/ to /etc/nginx/sites-enabled/ using cp command.
Now you need to find lines similar to below:
server {
listen 443 ssl;
ssl_certificate /etc/ssl/certificate.crt;
ssl_certificate_key /etc/ssl/private.key;
ssl_certificate and ssl_certificate_key are the only 2 lines we need to update here. Update these 2 lines with correct paths of merged cert file and key file,
ssl_certificate /etc/ssl/cert.crt;
ssl_certificate_key /etc/ssl/private.pem
Finally, save the config changes.
4. Restart Nginx server for SSL changes to take effect
Nginx server can be restarted using below SSH command
sudo service nginx restart
Once after successful restart, your HTTPs site should be working perfectly!.