How to Install Free SSL Certificate for Nginx on Debian 10

How to Install Free SSL Certificate for Nginx on Debian 10
TLS and SSL protocols cipher the connection between a site (or other service, but in this tutorial Nginx is the focus) and a client or web browser avoiding sniffers or MiM (Man in the Middle) attack from spying communication. A couple of years ago Google demanded all webmasters to use SSL, also for sites  without sensitive information exchange making this protocol a must also for marketing purposes (SEO).

This tutorial shows how to install a free SSL certificate for Nginx on Debian 10 using Certbot.

For users who haven’t installed Nginx yet the tutorial starts with a fast introduction to Nginx installation and configuration to show the site linux.bz, users who already have Nginx installed and configured can jump to How to Install Free SSL Certificate for Nginx on Debian 10.

Installing Nginx on Debian 10 Buster

Nginx was developed for high performance supporting millions of connections  simultaneously. While by default it can only serve static sites contrary to Apache which can serve both static and dynamic sites, dynamic sites may be also served with Nginx aided by Apache or other software.
If you have Nginx not installed on your PC yet this section will show its installation and configuration, if you have Nginx already installed jump to How to Install Free SSL Certificate for Nginx on Debian 10.

To begin installing Nginx on Debian 10 Buster, previous Debian versions or based Linux distributions run:

# apt install nginx -y

You should be able to access your web server through your browser at http://127.0.0.1/ (localhost).

Now create a configuration file for your website using nano, on the terminal run:

# nano /etc/nginx/sites-available/linux.bz

Within the newly created file input the content shown in the image below, replacing linux.bz for your domain name.

server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/linux.bz;
index index.html;
server_name linux.bz www.linux.bz;
location / {
try_files $uri $uri/ =404;
}
}

After adding the lines above (replacing linux.bz for your domain), press CTRL+X to save and exit the nano text editor.

Then create a symbolic link to /etc/nginx/sites-enabled/linux.bz by running:

# ln -s /etc/nginx/sites-available/linux.bz /etc/nginx/sites-enabled/linux.bz

Now create a directory /var/www/<yourdomain>

In my case:

# mkdir /var/www/linux.bz

# sudo service nginx start

Now you should be able to access your website through nginx with your browser:

Note for domestic users:

In order to allow access from outside the network, some home users will need to configure their routers to forward necessary ports to their web servers. The following image only shows an example of router configuration page for port forwarding, in your router you’ll need to forward ports 80 and 443 to your Apache computer local IP address.

How to Install Free SSL Certificate for Nginx on Debian 10

The free SSL installation process for Nginx under Debian 10 Buster is pretty easy and fast thanks to Certbot which makes Lets Encrypt SSL certificates easy to install.

You can install Certbot  on Debian 10 Buster by running the following command:

# apt install certbot python-certbot-nginx -y

To start the configuration process to add a SSL certificate to Nginx and redirect all http traffic to https run:

# sudo certbot –nginx

You can fill all requested fields or leave them blank, the last step allows you to automatically configure Nginx to redirect all unsecure traffic through https.

Conclusion on Free SSL Certificate for Nginx on Debian 10 Buster

The process to install a  free SSL certificate for Nginx on Debian 10 Buster is pretty simple and fast thanks to Certbot. The whole process took minutes to install the Nginx web server and configure it with SSL.

Other free options to get free SSL certificates may include SSL for Free (https://sslforfree.com, the short Comodo free SSL licences or Zerossl which I didn’t try yet, but none of them means a quick and simple way like this one.

I hope you found this brief article on How to Install Free SSL Certificate for Nginx on Debian 10 useful, thank you for reading it.

Other Articles related to How to Install Free SSL Certificate for Nginx on Debian 10

Related Posts
Leave a Reply

Your email address will not be published.Required fields are marked *