77# nginx-acme
88
99nginx-acme is an [ NGINX] module with the implementation of the automatic
10- certificate management ([ ACMEv2] ) protocol.
10+ certificate management (ACMEv2) protocol.
11+
12+ The module implements following specifications:
13+
14+ * [ RFC8555] (Automatic Certificate Management Environment) with limitations:
15+ * Only HTTP-01 challenge type is supported
16+ * External account binding is not supported
1117
1218[ NGINX ] : https://nginx.org/
13- [ ACMEv2 ] : https://www.rfc-editor.org/rfc/rfc8555.html
19+ [ RFC8555 ] : https://www.rfc-editor.org/rfc/rfc8555.html
1420
1521## Getting Started
1622
1723### Requirements
1824
19- - Regular NGINX build dependencies: C compliler , make, PCRE2, Zlib
25+ - Regular NGINX build dependencies: C compiler , make, PCRE2, Zlib
2026- System-wide installation of OpenSSL 1.1.1 or later
2127- Rust toolchain (1.81.0 or later)
2228- [ libclang] for rust-bindgen
@@ -25,11 +31,11 @@ certificate management ([ACMEv2]) protocol.
2531
2632### Building
2733
28- One way to build the module is to export a path to a pre-built nginx source
34+ One way to build the module is to export a path to a configured NGINX source
2935tree and run ` cargo ` .
3036
3137``` sh
32- # checkout, configure and build nginx at ../nginx
38+ # checkout, configure and build NGINX at ../nginx
3339cd nginx-acme
3440export NGINX_BUILD_DIR=$( realpath ../nginx/objs)
3541cargo build --release
@@ -40,7 +46,7 @@ The result will be located at `target/release/libnginx_acme.so`.
4046Another way is to use the provided config script:
4147
4248``` sh
43- # in the nginx source directory
49+ # in the NGINX source directory
4450auto/configure \
4551 --with-compat \
4652 --with-http_ssl_module \
@@ -52,9 +58,29 @@ The result will be located at `objs/ngx_http_acme_module.so`.
5258Currently this method produces a slightly larger library, as we don't instruct
5359the linker to perform LTO and remove unused code.
5460
61+ ### Testing
62+
63+ The repository contains an integration test suite based on the [ nginx-tests] .
64+ The following command will build the module and run the tests:
65+
66+ ``` sh
67+ # Path to the nginx source checkout, defaults to ../nginx if not specified.
68+ export NGINX_SOURCE_DIR=$( realpath ../nginx)
69+ # Path to the nginx-tests checkout; defaults to ../nginx/tests if not specified.
70+ export NGINX_TESTS_DIR=$( realpath ../nginx-tests)
71+
72+ make test
73+ ```
74+
75+ Most of the tests require [ pebble] test server binary in the path, or in a
76+ location specified via ` TEST_NGINX_PEBBLE_BINARY ` environment variable.
77+
78+ [ nginx-tests ] : https://github.com/nginx/nginx-tests
79+ [ pebble ] : https://github.com/letsencrypt/pebble
80+
5581## How to Use
5682
57- Add the module to the nginx configuration and configure as described below.
83+ Add the module to the NGINX configuration and configure as described below.
5884Note that this module requires a [ resolver] configuration in the ` http ` block.
5985
6086[ resolver ] : https://nginx.org/en/docs/http/ngx_http_core_module.html#resolver
@@ -66,12 +92,12 @@ resolver 127.0.0.1:53;
6692
6793acme_issuer example {
6894 uri https://acme.example.com/directory;
69- contact admin@example.test;
70- state_path /var/lib /nginx/acme-example;
95+ # contact admin@example.test;
96+ state_path /var/cache /nginx/acme-example;
7197 accept_terms_of_service;
7298}
7399
74- acme_shared_zone zone=acme_shared :1M;
100+ acme_shared_zone zone=ngx_acme_shared :1M;
75101
76102server {
77103 listen 443 ssl;
@@ -82,6 +108,7 @@ server {
82108 ssl_certificate $acme_certificate;
83109 ssl_certificate_key $acme_certificate_key;
84110
111+ # do not parse the certificate on each request
85112 ssl_certificate_cache max=2;
86113}
87114
@@ -116,8 +143,8 @@ Defines an ACME certificate issuer object.
116143** Context:** acme_issuer
117144
118145The [ directory URL] ( https://www.rfc-editor.org/rfc/rfc8555#section-7.1.1 )
119- of the ACME server. This is the only mandatory parameter in the
120- [ ] ( #acme_issuer ) block.
146+ of the ACME server. This is the only mandatory directive in the
147+ [ acme_issuer ] ( #acme_issuer ) block.
121148
122149### account_key
123150
@@ -128,14 +155,16 @@ of the ACME server. This is the only mandatory parameter in the
128155** Context:** acme_issuer
129156
130157The account's private key used for request authentication.
158+
131159Accepted values:
132160
133- - ` ecdsa:256/384/521 ` for ` ES256 ` / ` ES384 ` / ` ES512 ` JSON Web Signature algorithms
134- - ` rsa:2048..4096 ` for ` RS256 ` .
161+ - ` ecdsa:256/384/521 ` for ` ES256 ` , ` ES384 ` or ` ES512 ` JSON Web Signature
162+ algorithms
163+ - ` rsa:2048/3072/4096 ` for ` RS256 ` .
135164- File path for an existing key, using one of the algorithms above.
136165
137166The generated account keys are preserved across reloads, but will be lost on
138- restart unless [ ] ( #state_path ) is configured.
167+ restart unless [ state_path ] ( #state_path ) is configured.
139168
140169### contact
141170
@@ -145,12 +174,11 @@ restart unless [](#state_path) is configured.
145174
146175** Context:** acme_issuer
147176
148- An array of URLs that the ACME server can use to contact the client for issues
149- related to this account. The ` mailto: ` scheme will be assumed unless specified
177+ Sets an array of URLs that the ACME server can use to contact the client
178+ regarding account issues.
179+ The ` mailto: ` scheme will be assumed unless specified
150180explicitly.
151181
152- Can be specified multiple times.
153-
154182### ssl_trusted_certificate
155183
156184** Syntax:** ssl_trusted_certificate ` file `
@@ -171,7 +199,7 @@ the certificate of the ACME server.
171199
172200** Context:** acme_issuer
173201
174- Enables or disables verification of the ACME servier certificate.
202+ Enables or disables verification of the ACME server certificate.
175203
176204### state_path
177205
@@ -182,11 +210,11 @@ Enables or disables verification of the ACME servier certificate.
182210** Context:** acme_issuer
183211
184212Defines a directory for storing the module data that can be persisted across
185- restarts. This could greatly improve the time until the server is ready and
186- help with rate-limiting ACME servers.
213+ restarts. This can significantly improve the time until the server is ready
214+ and help with rate-limiting ACME servers.
187215
188- The directory, if configured, will contain sensitive content:
189- the account key, the issued certificates and private keys.
216+ The directory contains sensitive content, such as the account key, issued
217+ certificates, and private keys.
190218
191219### accept_terms_of_service
192220
@@ -196,11 +224,10 @@ the account key, the issued certificates and private keys.
196224
197225** Context:** acme_issuer
198226
199- Agree to the terms under which the ACME server is to be used.
200-
201- Some servers require the user to agree with the terms of service before
202- registering an account. The text is usually available on the ACME server's
203- website and the URL will be printed to the error log if necessary.
227+ Agrees to the terms of service under which the ACME server will be used.
228+ Some servers require accepting the terms of service before account registration.
229+ The terms are usually available on the ACME server's website and the URL will
230+ be printed to the error log if necessary.
204231
205232### acme_shared_zone
206233
@@ -210,11 +237,13 @@ website and the URL will be printed to the error log if necessary.
210237
211238** Context:** http
212239
213- An optional directive that allows increasing the size of in-memory storage of
214- the module.
240+ Allows increasing the size of in-memory storage of the module.
215241The shared memory zone will be used to store the issued certificates, keys and
216242challenge data for all the configured certificate issuers.
217243
244+ The default zone size is sufficient to hold ~ 50 ECDSA prime256v1 keys or
245+ ~ 35 RSA 2048 keys.
246+
218247### acme_certificate
219248
220249** Syntax:** acme_certificate ` issuer ` [ ` identifier ` ...] [ ` key ` = ` alg[:size] ` ]
@@ -226,31 +255,30 @@ challenge data for all the configured certificate issuers.
226255Defines a certificate with the list of ` identifier ` s requested from
227256issuer ` issuer ` .
228257
229- The explicit list of identifiers can be omitted. In this case the identifiers
258+ The explicit list of identifiers can be omitted. In this case, the identifiers
230259will be taken from the [ server_name] directive in the same ` server ` block.
231- Not all the values accepted by [ server_name] are valid certificate identifiers:
260+ Not all values accepted in the [ server_name] are valid certificate identifiers:
232261regular expressions and wildcards are not supported.
233262
234263[ server_name ] : https://nginx.org/en/docs/http/ngx_http_core_module.html#server_name
235264
236- The ` key ` parameter sets the type of a generated private key. Supported key
237- algorithms and sizes:
238- ` ecdsa:256 ` (default), ` ecdsa:384 ` ,
239- ` ecdsa:521 ` ,
240- ` rsa:2048 ` .. ` rsa:4096 ` .
265+ The ` key ` parameter sets the type of a generated private key.
266+ Supported key algorithms and sizes:
267+ ` ecdsa:256 ` (default), ` ecdsa:384 ` , ` ecdsa:521 ` ,
268+ ` rsa:2048 ` , ` rsa:3072 ` , ` rsa:4096 ` .
241269
242270## Embedded Variables
243271
244272The ` ngx_http_acme_module ` module defines following embedded
245273variables, valid in the ` server ` block with the
246274[ acme_certificate] ( #acme_certificate ) directive:
247275
248- ### `` $acme_certificate ` `
276+ ### ` $acme_certificate `
249277
250278SSL certificate that can be passed to the
251279[ ssl_certificate] ( https://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_certificate ) .
252280
253- ### `` $acme_certificate_key ` `
281+ ### ` $acme_certificate_key `
254282
255283SSL certificate private key that can be passed to the
256284[ ssl_certificate_key] ( https://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_certificate_key ) .
0 commit comments