Skip to content

Commit ce558c7

Browse files
authored
doc(readme) add declarative configuration sample (#37)
1 parent 3edb169 commit ce558c7

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

README.md

+37-6
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ set `KONG_LUA_SSL_TRUSTED_CERTIFICATE` as environment instead of changing `kong.
1717

1818
#### Enable the Plugin
1919

20-
For all the domains that you need to get certificate, make sure `DOMAIN/.well-known/acme-challenge`
20+
For each the domain that needs a certificate, make sure `DOMAIN/.well-known/acme-challenge`
2121
is mapped to a Route in Kong. You can check this by sending
2222
`curl KONG_IP/.well-known/acme-challenge/x -H "host:DOMAIN"` and expect a response `Not found`.
2323
From plugin version 0.2.4, you can also [use the Admin API](#create-certificates) to
24+
verify the setup.
2425
If not, add a Route and a dummy Service to catch this route.
2526
```bash
2627
# add a dummy service if needed
@@ -60,11 +61,11 @@ Assume Kong proxy is accessible via http://mydomain.com and https://mydomain.com
6061
# Wait up to 1 minute for the background process to finish
6162
$ curl https://mydomain.com -k
6263

63-
# OR create from Admin API with version >= 0.2.4
64+
# OR create from Admin API synchronously with version >= 0.2.4
6465
# User can also use this endpoint to force "renew" a certificate
6566
$ curl http://localhost:8001/acme -d host=mydomain.com
6667

67-
# Furthermore, it's possible to run sanity test on your Kong setup
68+
# Furthermore, it's possible to run a sanity test on your Kong setup
6869
# before creating any certificate
6970
$ curl http://localhost:8001/acme -d host=mydomain.com -d test_http_challenge_flow=true
7071

@@ -90,11 +91,11 @@ $ curl http://localhost:8001/acme -XPATCH
9091
Name | Required | Default | Description
9192
-------------------:|------------|------------|------------
9293
config.account_email| Yes | | The account identifier, can be reused in different plugin instance.
93-
config.api_uri | | `"https://acme-v02.api.letsencrypt.org/directory"` | The ACMEv2 API endpoint to use, the url should only contain root path. User might use [Let's Encrypt staging environemnt](https://letsencrypt.org/docs/staging-environment/)(`https://acme-staging-v02.api.letsencrypt.org/directory`) during testing. Kong doesn't automatically delete staging certificates, if you use same domain to test and use in production, you will need to delete those certificates manaully after test.
94-
config.cert_type | | `"rsa"` | The certificate type to create, choice of `"rsa"` for RSA certificate or `"ecc"` for EC certificate.
94+
config.api_uri | | `"https://acme-v02.api.letsencrypt.org/directory"` | The ACMEv2 API endpoint to use. Users can specify the [Let's Encrypt staging environment](https://letsencrypt.org/docs/staging-environment/) (`https://acme-staging-v02.api.letsencrypt.org/directory`) for testing. Note that Kong doesn't automatically delete staging certificates: if you use same domain to test and use in production, you will need to delete those certificates manaully after test.
95+
config.cert_type | | `"rsa"` | The certificate type to create. The possible values are `"rsa"` for RSA certificate or `"ecc"` for EC certificate.
9596
config.domains | | `[]` | The list of domains to create certificate for. To match subdomains under `example.com`, use `*.example.com`. Regex pattern is not supported. Note this config is only used to match domains, not to specify the Common Name or Subject Alternative Name to create certifcates; each domain will have its own certificate.
9697
config.renew_threshold_days| | `14` | Days before expire to renew the certificate.
97-
config.storage | | `"shm"` | The backend storage type to use, choice of `"kong"`, `"shm"`, `"redis"`, `"consul"` or `"vault"`. In dbless mode, `"kong"` storage is unavailable. Note `"shm"` storage does not persist during Kong restarts and does not work for Kong running on different machines, consider using one of `"kong"`, `"redis"`, `"consul"` or `"vault"` in production.
98+
config.storage | | `"shm"` | The backend storage type to use. The possible values are `"kong"`, `"shm"`, `"redis"`, `"consul"`, or `"vault"`. In DB-less mode, `"kong"` storage is unavailable. Note that `"shm"` storage does not persist during Kong restarts and does not work for Kong running on different machines, so consider using one of `"kong"`, `"redis"`, `"consul"`, or `"vault"` in production.
9899
config.storage_config| | (See below)| Storage configs for each backend storage.
99100
config.tos_accepted | | `false` | If you are using Let's Encrypt, you must set this to true to agree the [Terms of Service](https://letsencrypt.org/repository/).
100101

@@ -136,6 +137,36 @@ To configure storage type other than `kong`, please refer to [lua-resty-acme](ht
136137

137138
Note `tls_verify` and `tls_server_name` parameters for Vault are only supported from plugin version 0.2.7.
138139

140+
Here's a sample declarative configuration with `redis` as storage:
141+
142+
```yaml
143+
_format_version: "1.1"
144+
# this section is not necessary if there's already a route that matches
145+
# /.well-known/acme-challenge path with http protocol
146+
services:
147+
- name: acme-dummy
148+
url: http://127.0.0.1:65535
149+
routes:
150+
- name: acme-dummy
151+
protocols:
152+
- http
153+
paths:
154+
- /.well-known/acme-challenge
155+
plugins:
156+
- name: acme
157+
config:
158+
account_email: [email protected]
159+
domains:
160+
- "*.example.com"
161+
- "example.com"
162+
tos_accepted: true
163+
storage: redis
164+
storage_config:
165+
redis:
166+
host: redis.service
167+
port: 6379
168+
```
169+
139170
### Local testing and development
140171
141172
#### Run ngrok

0 commit comments

Comments
 (0)