How to Install Letsencrypt Certificates With Certbot in Ubuntu 16.04

by admin Date: 02-10-2018 ubuntu linux ssl certbot letsencrypt


Install Certbot's Nginx package with apt-get.

sudo apt-get install python-certbot-nginx
sudo certbot -i nginx -a webroot -w /var/www/mysite.org -d www.mysite.org

edit the nginx config file for /etc/nginx/sites-available/default.

server {
        listen 443 ssl;

        server_name mysite.org;
	ssl_certificate /etc/letsencrypt/live/mysite.org/fullchain.pem;
	ssl_certificate_key /etc/letsencrypt/live/mysite.org/privkey.pem;

        location / {
            proxy_pass http://127.0.0.1:80;
            proxy_set_header X-Real-IP  $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto https;
            proxy_set_header X-Forwarded-Port 443;
            proxy_set_header Host $host;
        }
        
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
}

test renew

certbot renew --dry-run

Create a file /root/letsencrypt.sh:

#!/bin/bash
systemctl reload nginx

Make it executable:

chmod +x /root/letsencrypt.sh

Edit cron:

sudo crontab -e

And add the line:

20 3 * * * certbot renew --noninteractive --renew-hook /root/letsencrypt.sh
 
by admin Date: 02-10-2018 ubuntu linux ssl certbot letsencrypt hits : 998  
 
 
 
 

Related Posts