letsencrypt
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| letsencrypt [2016/04/27 10:49] – created k2patel | letsencrypt [2020/08/10 02:35] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Letsencrypt ====== | + | ====== Letsencrypt |
| + | Now they renamed it from Letsencrypt to Certbot.\\ | ||
| + | Working on script to reflect the change but i have to make sure it does not change | Break all required dependencies.\\ | ||
| Great thing happen securing internet servers, And it's Free.\\ | Great thing happen securing internet servers, And it's Free.\\ | ||
| But there is catch, You have to renew your certificated Often.\\ | But there is catch, You have to renew your certificated Often.\\ | ||
| Since they provided tool to do so, i don't think there is problem at all.\\ | Since they provided tool to do so, i don't think there is problem at all.\\ | ||
| + | |||
| + | One thing, i've noticed that on AWS, some how authentication using the webroot method fails.\\ | ||
| + | So i had to use http method, which works perfectly fine.\\ | ||
| + | But, renewal works without any issue using webroot.\\ | ||
| First install command line API tool. | First install command line API tool. | ||
| Line 15: | Line 21: | ||
| </ | </ | ||
| + | ==== configuration for certificate request / location ==== | ||
| //It is good idea to create config file for each certificate because we can use it for renewal// | //It is good idea to create config file for each certificate because we can use it for renewal// | ||
| <code ini sample_config> | <code ini sample_config> | ||
| # Domain which you are trying to get certificate for; | # Domain which you are trying to get certificate for; | ||
| + | # multiple domain like aliases can be saperated by comma | ||
| + | # e.g. domains = wiki.k2patel.in, | ||
| domains = wiki.k2patel.in | domains = wiki.k2patel.in | ||
| Line 38: | Line 47: | ||
| </ | </ | ||
| + | ==== Nginx configuration ==== | ||
| + | I'm using https redirect for my hosts so i use following code on each domain.\\ | ||
| + | Works fine for me. | ||
| + | <code conf nginx.conf> | ||
| + | if ($request_uri !~ " | ||
| + | rewrite | ||
| + | } | ||
| + | location / | ||
| + | root / | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | SSL Configuration | ||
| + | <code conf ssl.conf> | ||
| + | ssl on; | ||
| + | ssl_certificate_key / | ||
| + | ssl_certificate / | ||
| + | ssl_trusted_certificate / | ||
| + | </ | ||
| + | ==== Apache Configuration ==== | ||
| + | So each domain only need to redirect to HTTPS if URL requested is from acme. | ||
| + | |||
| + | <code conf domain.conf> | ||
| + | RewriteEngine On | ||
| + | RewriteCond %{REQUEST_URI} !^/ | ||
| + | RewriteCond %{HTTPS} off | ||
| + | RewriteRule ^(.*)$ https:// | ||
| + | </ | ||
| + | |||
| + | |||
| + | SSL configuration | ||
| + | <code conf ssl.conf> | ||
| + | SSLEngine on | ||
| + | SSLCertificateFile | ||
| + | SSLCertificateKeyFile | ||
| + | SSLCACertificatePath | ||
| + | SSLCertificateChainFile "/ | ||
| + | </ | ||
| + | ==== Cron setup ==== | ||
| + | Now i have script which run every 11 week. | ||
| + | |||
| + | <code bash letsrenew> | ||
| + | # | ||
| + | # | ||
| + | ############# | ||
| + | # | ||
| + | # Renew Certificate using lets-encrypt | ||
| + | # Author : Ketan Patel < | ||
| + | # License : BSD | ||
| + | # | ||
| + | ############# | ||
| + | source /etc/bashrc | ||
| + | |||
| + | # Globals ( Please update ) | ||
| + | # | ||
| + | ldomains=(' | ||
| + | LETSENCRYPT_HOME="/ | ||
| + | WEBSERVER=" | ||
| + | |||
| + | # Enable System level logging | ||
| + | # Redirect log to logger | ||
| + | exec 1> >(logger -t $(basename $0)) 2>&1 | ||
| + | |||
| + | for i in ${ldomains[@]} | ||
| + | do | ||
| + | ${LETSENCRYPT_HOME}/ | ||
| + | done | ||
| + | |||
| + | # Start web services | ||
| + | if / | ||
| + | echo "Web service re-started after certificate renewal." | ||
| + | else | ||
| + | echo " | ||
| + | fi | ||
| + | </ | ||
letsencrypt.1461754165.txt.gz · Last modified: 2020/08/10 02:30 (external edit)
