Community Blog Quick Guide! How to Install a Free SSL Certificate on NGINX Web Server

Quick Guide! How to Install a Free SSL Certificate on NGINX Web Server

In this guide, we are going to install a free SSL certificate on the NGINX web server.

SSL certificates allow websites to switch from HTTP to HTTPS. This is safer. An SSL certificate is a file that is stored on a website's source server. SSL certificates enable SSL/TLS encryption.

They contain the website’s public key, website identity, and other information. To verify the identity of the origin server, devices will refer to this file when they attempt to communicate with it. The private key is kept confidential and protected.

So, let's get started


In order to install the SSL certificate on your NGINX web server, you need to have an NGINX installed on ubuntu 21.04. we are going to use Alibaba ECS Instance for this guide.

If you don't have NGINX installed on your server you can follow this guide -

How to install NGINX on Ubuntu 21.04

Step 1 - Login to your server via SSH

First of all, connect your instance via SSH. You can connect by using this command.

ssh username@your-public-ip-address

Step 2 - Create Virtual Host

Create a Config file same as Default Config which is by default given by Nginx. Include your complete domain name. This will ensure that there is no syntax error.

You can use this command to copy the existing config file to the new one.

sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/www.example.com

Step 3 - Configure the NGINX Configuration file

Now open the file with nano editor ( you can use whatever you want) by using this command

sudo nano /etc/nginx/sites-available/www.example.com

Replace www.example.com with your domain name.

Now to save this file press CTRL+X, Y, and Enter.

Step 4 - Unlink the default NGINX Configuration File

In order to use your new NGINX configuration file, we have to unlink the default configuration file.

You can do that by using this command

sudo unlink /etc/nginx/sites-enabled/default

Step 5 - Link our new config file

Next, we have to create a symlink to the NGINX-enabled directory. We can create this symlink by typing:

sudo ln -s /etc/nginx/sites-available/www.example.com /etc/nginx/sites-enabled/www.example.com

Step 6 - Test configuration error

After editing all these configurations we have to make sure that there is no syntax error.

we can confirm that by using this command

sudo nginx -t

Step 7 - Restart the NGINX server

We can now restart our NGINX web server to make those changes effective

sudo systemctl restart nginx

Step 8 - Open 443 Port in your firewall

In order to use HTTPS ( SSL Certificate ), we have to allow 443 port in our firewall.

Make sure you enabled 443 port.

Step 9 - Install Certbot

Certbot is an open-source software tool that automatically enables HTTPS using Let’s Encrypt certificates.

To install certbot on ubuntu we can use this command :

sudo apt install certbot python3-certbot-nginx

Press Y to confirm it

Step 10 - Obtain the SSL Certificate

NGINX's Certbot plugin reconfigures Nginx, and reloads its configuration when necessary. The NGINX plug-in is all you need to generate certificates.

We can use this command to generate SSL certificate

sudo certbot --nginx -d example.com -d www.example.com

It will ask you to enter your mail ID where you will get the SSL expiry-related information.

Now Agree with the term and conditions.

Finally, the output displays that you have successfully generated a certificate and specifies the location of the certificate on your server.


SSL certificate should be installed on your NGINX web server. if you have any questions regarding this, please let us know in the comment section.

Thank You!

0 1 1
Share on

Arman Ali

3 posts | 1 followers

You may also like


Arman Ali

3 posts | 1 followers

Related Products