Skip to content

Commit 281aa02

Browse files
TreeN0debuchdag
authored andcommitted
docs: acme.sh pre and post hooks
1 parent 9da38f3 commit 281aa02

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

docs/Container-configuration.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,8 @@ You can also create test certificates per container (see [Test certificates](./L
2828

2929
* `CA_BUNDLE` - This is a test only variable [for use with Pebble](https://github.com/letsencrypt/pebble#avoiding-client-https-errors). It changes the trusted root CA used by `acme.sh`, from the default Alpine trust store to the CA bundle file located at the provided path (inside the container). Do **not** use it in production unless you are running your own ACME CA.
3030

31-
* `CERTS_UPDATE_INTERVAL` - 3600 seconds by default, this defines how often the container will check if the certificates require update.
31+
* `CERTS_UPDATE_INTERVAL` - 3600 seconds by default, this defines how often the container will check if the certificates require update.
32+
33+
* `ACME_PRE_HOOK` - The provided command will be run before every certificate issuance. The action is limited to the commands available inside the **acme-companion** container. For example `--env "ACME_PRE_HOOK=echo 'start'"`. For more information see [Pre- and Post-Hook](./Hooks.md)
34+
35+
* `ACME_POST_HOOK` - The provided command will be run after every certificate issuance. The action is limited to the commands available inside the **acme-companion** container. For example `--env "ACME_POST_HOOK=echo 'end'"`. For more information see [Pre- and Post-Hook](./Hooks.md)

docs/Hooks.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
## Pre-Hooks and Post-Hooks
2+
3+
The Pre- and Post-Hooks of [acme.sh](https://github.com/acmesh-official/acme.sh/) are available through the corresponding environment variables. This allows to trigger actions just before and after certificates are issued (see [acme.sh documentation](https://github.com/acmesh-official/acme.sh/wiki/Using-pre-hook-post-hook-renew-hook-reloadcmd))
4+
5+
#### Pre-Hook
6+
This command will be run before certificates are issued. For example `echo 'start'`:
7+
```shell
8+
$ docker run --detach \
9+
--name nginx-proxy-acme \
10+
--volumes-from nginx-proxy \
11+
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
12+
--volume acme:/etc/acme.sh \
13+
--env "DEFAULT_EMAIL=mail@yourdomain.tld" \
14+
--env "ACME_PRE_HOOK=echo 'start'"
15+
nginxproxy/acme-companion
16+
```
17+
18+
#### Post-Hook
19+
This command will be run after certificates are issued. For example `echo 'end'`:
20+
```shell
21+
$ docker run --detach \
22+
--name nginx-proxy-acme \
23+
--volumes-from nginx-proxy \
24+
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
25+
--volume acme:/etc/acme.sh \
26+
--env "DEFAULT_EMAIL=mail@yourdomain.tld" \
27+
--env "ACME_POST_HOOK=echo 'end'"
28+
nginxproxy/acme-companion
29+
```
30+
31+
#### Verification:
32+
If you want to check wether the hook-command is delivered properly to [acme.sh](https://github.com/acmesh-official/acme.sh/), you should check `/etc/acme.sh/[EMAILADDRESS]/[DOMAIN]/[DOMAIN].conf`.
33+
The variable `Le_PreHook` contains the Pre-Hook-Command base64 encoded.
34+
The variable `Le_PostHook` contains the Pre-Hook-Command base64 encoded.
35+
36+
#### Limitations
37+
* The commands that can be used in the hooks are limited to the commands available inside the **acme-companion** container. `curl` and `wget` are available, therefore it is possible to communicate with tools outside the container via HTTP, allowing for complex actions to be implemented outside or in other containers.
38+
* The hooks are general options, therefore **the actions for all certificates are the same**.
39+
40+
#### Use-cases
41+
* Change some firewall rules just for the issuing process of the certificates, so the ports 80 and/or 443 don't have to be publicly reachable at all time.
42+
* Monitoring.

docs/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
[Zero SSL](./Zero-SSL.md)
2424

25+
[Pre-Hooks and Post-Hooks](./Hooks.md)
26+
2527
#### Troubleshooting:
2628

2729
[Invalid / failing authorizations](./Invalid-authorizations.md)

0 commit comments

Comments
 (0)