Certbot: Difference between revisions

From Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
The <code>certbot</code> connects to Let's Encrypt to obtain an SSL certificate for your server.
The <code>certbot</code> connects to Let's Encrypt to obtain an SSL certificate for your server.


* Install packages
<pre>
<pre>
sudo add-apt-repository ppa:certbot/certbot
sudo add-apt-repository ppa:certbot/certbot
Line 11: Line 12:
</pre>
</pre>


Create the file <code>/etc/nginx/snippets/ssl-certbot-renewal.conf</code>:
* Create the file <code>/etc/nginx/snippets/ssl-certbot-renewal.conf</code>:
<pre>
<pre>
# support for certbot ssl auto-renewal
# support for certbot ssl auto-renewal
Line 20: Line 21:
</pre>
</pre>


Include the following line in the ssl config for each domain:
* Include the following line in the ssl config for each domain:
<pre>
<pre>
include snippets/ssl-certbot-renewal.conf;
include snippets/ssl-certbot-renewal.conf;
</pre>
</pre>


Restart nginx
* Restart nginx


Now run a command like this:
* Now run a command like this:
<pre>
<pre>
certbot certonly --webroot --webroot-path=/var/www/html \
certbot certonly --webroot --webroot-path=/var/www/html \
Line 35: Line 36:
</pre>
</pre>


Test with this:
* Test with this:
<pre>
<pre>
sudo certbot renew --dry-run
sudo certbot renew --dry-run
</pre>
</pre>

Revision as of 18:06, 19 April 2018

https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04

The certbot connects to Let's Encrypt to obtain an SSL certificate for your server.

  • Install packages
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-nginx
  • Create the file /etc/nginx/snippets/ssl-certbot-renewal.conf:
# support for certbot ssl auto-renewal
location ^~ /.well-known/ {
    default_type "text/plain";
    root /var/www/html/;
}
  • Include the following line in the ssl config for each domain:
include snippets/ssl-certbot-renewal.conf;
  • Restart nginx
  • Now run a command like this:
certbot certonly --webroot --webroot-path=/var/www/html \
-d example.com \
-d domain1.example.com \
-d domain2.example.com
  • Test with this:
sudo certbot renew --dry-run