SSL free with Certbot and nginx

Really simple with

Install Nginx

sudo apt install nginx
  • Update default config /etc/nginx/sites-available/default
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;
    index index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
  • Add virtual application by creating new config /etc/nginx/sites-available/
server {
    listen 80;
    listen [::]:80;

    root /home/nhancao/;
    index index.html index.htm;


    location / {
        try_files $uri $uri/ /index.html?$query_string;
  • Make alias
sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/
  • Reload config
sudo service nginx reload

Install Certbot for SSL

You should select Yes for all question in installation

sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository universe
sudo add-apt-repository ppa:certbot/certbot
sudo apt update

sudo apt install certbot python-certbot-nginx
sudo certbot --nginx

Another approach is using Cloud Flare:

Leave a Reply

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