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 -
First of all, connect your instance via SSH. You can connect by using this command.
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
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
www.example.com with your domain name.
Now to save this file press
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
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
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
We can now restart our NGINX web server to make those changes effective
sudo systemctl restart nginx
In order to use HTTPS ( SSL Certificate ), we have to allow
443 port in our firewall.
Make sure you enabled
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
Y to confirm it
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.
Alibaba Clouder - November 19, 2019
Alibaba Clouder - January 9, 2020
Alibaba Clouder - August 22, 2018
Alibaba Clouder - August 27, 2020
Alibaba Clouder - May 11, 2018
Alibaba Clouder - April 26, 2019
Alibaba Cloud SSL Certificates Service allows customers to directly apply, purchase and manage SSL certificates.Learn More
An elastic and horizontally scalable high-performance computing service providing the same computing performance as traditional physical servers including physical isolation.Learn More
An online computing service that offers elastic and secure virtual cloud servers to cater all your cloud hosting needs.Learn More