SSL free with Certbot and nginx

Really simple with https://certbot.eff.org/

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/nhancv.com
server {
    listen 80;
    listen [::]:80;

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

    server_name nhancv.com www.nhancv.com;

    location / {
        try_files $uri $uri/ /index.html?$query_string;
    }
}
  • Make alias
sudo ln -s /etc/nginx/sites-available/nhancv.com /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: https://www.cloudflare.com/ssl/

Leave a Reply

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