sudo adduser --system --home /opt/letsencrypt le sudo -u le -s git clone https://github.com/lukas2511/letsencrypt.sh.git /opt/letsencrypt/ mkdir /opt/letsencrypt/.acme-challenges echo CONTACT_EMAIL="your@email" > /opt/letsencrypt/config echo "_" > /opt/letsencrypt/domains.txt
location /.well-known/acme-challenge/ { alias /opt/letsencrypt/.acme-challenges/; }
sudo -u le /opt/letsencrypt/letsencrypt.sh --cron
listen 443 ssl; ssl_certificate /opt/letsencrypt/certs/_/fullchain.pem; ssl_certificate_key /opt/letsencrypt/certs/_/privkey.pem;
1 0 * * * /opt/letsencrypt/letsencrypt.sh --cron
$ sudo adduser --system --home /opt/letsencrypt le
$ sudo -u le -s $ git clone https://github.com/lukas2511/letsencrypt.sh.git /opt/letsencrypt/ $ ls -la /opt/letsencrypt/ total 84 drwxr-xr-x 4 le le 4096 Jun 25 15:56 . drwxr-xr-x 3 root root 4096 Jun 25 15:53 .. -rw-r--r-- 1 le le 1406 Jun 25 15:56 CHANGELOG drwxr-xr-x 3 le le 4096 Jun 25 15:56 docs drwxr-xr-x 8 le le 4096 Jun 25 15:56 .git -rw-r--r-- 1 le le 108 Jun 25 15:56 .gitignore -rwxr-xr-x 1 le le 37634 Jun 25 15:56 letsencrypt.sh -rw-r--r-- 1 le le 1080 Jun 25 15:56 LICENSE -rw-r--r-- 1 le le 3040 Jun 25 15:56 README.md -rwxr-xr-x 1 le le 8048 Jun 25 15:56 test.sh -rw-r--r-- 1 le le 107 Jun 25 15:56 .travis.yml
/opt/letsencrypt/.acme-challenges
folder and will fall with an error if there is no such folder./opt/letsencrypt/config
file. By default, there is no file and the script uses default values, but there is a well-documented config in the documentation folder that can be taken as a basis. $ mkdir /opt/letsencrypt/.acme-challenges $ cp /opt/letsencrypt/docs/examples/config /opt/letsencrypt/config
--env
$ /opt/letsencrypt/letsencrypt.sh --env # letsencrypt.sh configuration # # !! WARNING !! No main config file found, using default config! # declare -- CA="https://acme-v01.api.letsencrypt.org/directory" declare -- LICENSE="https://letsencrypt.org/documents/LE-SA-v1.0.1-July-27-2015.pdf" declare -- CERTDIR="/opt/letsencrypt/certs" declare -- CHALLENGETYPE="http-01" declare -- DOMAINS_TXT="/opt/letsencrypt/domains.txt" declare -- HOOK="" declare -- HOOK_CHAIN="no" declare -- RENEW_DAYS="30" declare -- ACCOUNT_KEY="/opt/letsencrypt/accounts/aHR0cHM6Ly9hY21lLXYwMS5hcGkubGV0c2VuY3J5cHQub3JnL2RpcmVjdG9yeQo/account_key.pem" declare -- ACCOUNT_KEY_JSON="/opt/letsencrypt/accounts/aHR0cHM6Ly9hY21lLXYwMS5hcGkubGV0c2VuY3J5cHQub3JnL2RpcmVjdG9yeQo/registration_info.json" declare -- KEYSIZE="4096" declare -- WELLKNOWN="/opt/letsencrypt/.acme-challenges" declare -- PRIVATE_KEY_RENEW="yes" declare -- OPENSSL_CNF="/usr/lib/ssl/openssl.cnf" declare -- CONTACT_EMAIL="" declare -- LOCKFILE="/opt/letsencrypt/lock"
CA
- which certification authority to use. There are at least two of them - combat (by default) and test . The fact is that combat has different restrictions on the frequency of requests and the number of domains. It is easy to rest against these limitations when testing. Therefore, I recommend specifying a test center for test runs. It works in the same way as combat, it simply generates invalid certificates.CA="https://acme-staging.api.letsencrypt.org/directory"
CERTDIR
- folder for certificates. Inside it there are hotel folders by the host name. And in these folders are certificates for each host. You will need to configure nginx to read certificates from these folders (see below).DOMAINS_TXT
- list of domains. One line - one certificate. In one line there can be several domains, then one certificate is created for them. The script takes the first domain as the name of the certificate, and the remaining domains indicate as optional. For example, for such a file, the script will create two certificates: some.domain.com and test.com.some.domain.com another.domain.net example.domain.org
test.com www.test.org ftp.test.net
HOOK
is a script that runs on various actions (during domain validation, certificate generation, etc.)./opt/letsencrypt/docs/examples/hook.sh
RENEW_DAYS
- after how many days to renew the certificate. Maximum 90, default 30.CONTACT_EMAIL
- working email administrator.CONTACT_EMAIL
in CONTACT_EMAIL
in the CONTACT_EMAIL
and CONTACT_EMAIL
up a test CA
for the duration of the tests.letest.lexore.net
server { listen 80; server_name letest.lexore.net; location /.well-known/acme-challenge/ { alias /opt/letsencrypt/.acme-challenges/; } location / { default_type text/plain; return 200 "scheme: $scheme"; } }
location /.well-known/acme-challenge/
/opt/letsencrypt/.acme-challenges/
are created in the /opt/letsencrypt/.acme-challenges/
folder to confirm that you are managing the site._/.well-known/acme-challenge/
, otherwise the certificate will not be signed. $ curl -i letest.lexore.net HTTP/1.1 200 OK Server: nginx Date: Sun, 26 Jun 2016 13:13:18 GMT Content-Type: text/plain Content-Length: 12 Connection: keep-alive scheme: http
$ echo letest.lexore.net > /opt/letsencrypt/domains.txt $ /opt/letsencrypt/letsencrypt.sh --cron # INFO: Using main config file /opt/letsencrypt/config Processing letest.lexore.net + Signing domains... + Creating new directory /opt/letsencrypt/certs/letest.lexore.net ... + Generating private key... + Generating signing request... + Requesting challenge for letest.lexore.net... + Responding to challenge for letest.lexore.net... + Challenge is valid! + Requesting certificate... + Checking certificate... + Done! + Creating fullchain.pem... + Done!
/opt/letsencrypt/certs/letest.lexore.net
" folder. listen 443 ssl; ssl_certificate /opt/letsencrypt/certs/letest.lexore.net/fullchain.pem; ssl_certificate_key /opt/letsencrypt/certs/letest.lexore.net/privkey.pem;
--force
. le@endor:~$ /opt/letsencrypt/letsencrypt.sh --cron --force # INFO: Using main config file /opt/letsencrypt/config Processing letest.lexore.net + Checking domain name(s) of existing cert... unchanged. + Checking expire date of existing cert... + Valid till Sep 24 12:13:00 2016 GMT (Longer than 80 days). Ignoring because renew was forced! + Signing domains... + Generating private key... + Generating signing request... + Requesting challenge for letest.lexore.net... + Responding to challenge for letest.lexore.net... + Challenge is valid! + Requesting certificate... + Checking certificate... + Done! + Creating fullchain.pem... + Done!
subdomain.letest.lexore.net
. $ /opt/letsencrypt/letsencrypt.sh --cron --force # INFO: Using main config file /opt/letsencrypt/config Processing letest.lexore.net with alternative names: subdomain.letest.lexore.net + Checking domain name(s) of existing cert... changed! + Domain name(s) are not matching! + Names in old certificate: letest.lexore.net + Configured names: letest.lexore.net subdomain.letest.lexore.net + Forcing renew. + Checking expire date of existing cert... + Valid till Sep 24 12:48:00 2016 GMT (Longer than 80 days). Ignoring because renew was forced! + Signing domains... + Generating private key... + Generating signing request... + Requesting challenge for letest.lexore.net... + Requesting challenge for subdomain.letest.lexore.net... + Responding to challenge for letest.lexore.net... + Challenge is valid! + Responding to challenge for subdomain.letest.lexore.net... + Challenge is valid! + Requesting certificate... + Checking certificate... + Done! + Creating fullchain.pem... + Done!
0 1 * * * /opt/letsencrypt/letsencrypt.sh --cron
location /.well-known/acme-challenge/ { alias /opt/letsencrypt/.acme-challenges/; }
location /.well-known/acme-challenge/ { alias /opt/letsencrypt/.acme-challenges/; }
_
to domains.txt
/opt/letsencrypt/letsencrypt.sh --cron
listen 443 ssl; ssl_certificate /opt/letsencrypt/certs/_/fullchain.pem; ssl_certificate_key /opt/letsencrypt/certs/_/privkey.pem;
HOOK
in the config, which allows you to run your script.CONFIG_D
- a folder in which all .sh
scripts will be run to redefine the parameters of the main config.ACCOUNTDIR
- folders with private keys for signing requests.Source: https://habr.com/ru/post/304174/
All Articles