Installing an SSL certificate on NGINX
Updated: 2026-01-28 07:12:17 Viewed times: 849
1.Upload the certificate files
First, you need to upload the aforementioned certificate files (`certificate.crt`, `ca_bundle.crt`, and `private.key`) to the NGINX server in the directory of your choice.
2.Merge the `.crt` files
NGINX requires that all `.crt` files be merged together to enable SSL installation. You need to run the following command to merge your `scorter.crt` and `ca_bundle.crt` files:
$ cat ca_bundle.crt >> certificate.crt
3. Edit the virtual host file.
Next, you need to locate your NGINX virtual host file and add some code to point it to your new SSL certificate. After opening the virtual host file, create a copy of the existing insecure server module and paste it below the original module.
4.Please note
If you need to access your website via both HTTPS (secure) and HTTP (insecure) connections, you will need to provide a separate server module for each type of connection.
Add the bold text to your virtual host file:
server {
listen 443 ssl;
ssl on;
ssl_certificate /etc/ssl/certificate.crt;
ssl_certificate_key /etc/ssl/private.key;
server_name your.domain.com;
access_log /var/log/nginx/nginx.vhost.access.log;
error_log /var/log/nginx/nginx.vhost.error.log;
location / {
root /home/www/public_html/your.domain.com/public/;
index index.html;
}
}
5. Restart the server
Finally, you need to restart the NGINX server so that your changes take effect. You can run the following command to restart your NGINX server:
sudo /etc/init.d/nginx restart
6. Check the installation.
You have completed all the necessary steps to install the SSL certificate. To verify that your certificate has been installed correctly, simply try to access your domain name using HTTPS, for example, https://domain.com.