Installing SSL Certificate on Nginx

AiroServer's Blog

In our last post, we compared Nginx and LiteSpeed. These two are two popular Linux web servers. One of the things that we mentioned about Nginx was that it can’t be controlled by control panels like other web servers. Both Apache and LiteSpeed have their panels on DirectAdmin, cPanel and etc. Obviously, it’s much easier to install SSL using control panels like DA, cPanel, Plesk, CyberPanel, and etc but in this post, we’re going to show you how you can install SSL on Nginx.

Before installing SSL you need to finish ordering an SSL certificate and get the needed files from the provider. The files that you’re gonna need are:

  • The certificate file
  • Private key
  • CSR
  • Ca

*To get the private key, you can use online CSR Generators*. So just go to CSRgenerator.com and fill in the forms to get your CSR and private key so you can install SSL.

Installing SSL on Nginx

1. Login to the server using an SSH connection.

2. Go to the address below and create a .key and a .crt file.

etc/Nginx/SSL

So you’re going to create two files like your-domain-name.crt and your-domain-name.key using the touch command. Now copy what’s in the Private key file and paste it in the .key file. Then copy what’s in the certificate and ca file and paste it in the .crt file. Save your changes and go for the next step.

3. Now you need to edit the Nginx configuration file. To do that, go to nginx.conf and add this to the Nginx configuration file:

server {listen   ۴۴۳; ssl    on; ssl_certificate    /etc/ssl/your_domain_name.crt; ssl_certificate_key    /etc/ssl/your_domain_name.key;

Also, go to the Nginx virtual hosts file from the path below and add the same lines to it:

/etc/nginx/sites-available/yourdomain

The installation is complete and your SSL is ready to use.

Hope you enjoyed this post if you did, you can visit our blog for more!

Find More Articles...

Whats New?

en_USEN