1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
|
<?xml version="1.0"?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
<!-- $LastChangedRevision$ -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<modulesynopsis metafile="mod_md.xml.meta">
<name>mod_md</name>
<description>Managing domains across virtual hosts, certificate provisioning
via the ACME protocol
</description>
<status>Experimental</status>
<sourcefile>mod_md.c</sourcefile>
<identifier>md_module</identifier>
<compatibility>Available in version 2.4.30 and later</compatibility>
<summary>
<p>
This module manages common properties of domains for one or more virtual hosts.
Specifically it can use the ACME protocol
(<a href="https://datatracker.ietf.org/doc/draft-ietf-acme-acme/">RFC Draft</a>)
to automate certificate provisioning. These will be configured for managed domains and
their virtual hosts automatically. This includes renewal of certificates before they
expire. The most famous Certificate Authority currently implementing the ACME protocol
is <a href="https://letsencrypt.org/">Let's Encrypt</a>.</p>
<note type="warning"><title>Warning</title>
<p>This module is experimental. Its behaviors, directives, and
defaults are subject to more change from release to
release relative to other standard modules. Users are encouraged to
consult the "CHANGES" file for potential updates.</p>
</note>
<p>Simple configuration example:</p>
<note><title>TLS in a VirtualHost context</title>
<highlight language="config">
MDomain example.org
<VirtualHost *:443>
ServerName example.org
DocumentRoot htdocs/a
SSLEngine on
# no certificates specification
</VirtualHost>
</highlight>
<p>
This setup will, on server start, contact
<a href="https://letsencrypt.org/">Let's Encrypt</a>
to request a certificate for the domain. If Let's Encrypt can verify the ownership
of the domain, the module will retrieve the certificate and its chain, store it
in the local file system (see <directive module="mod_md">MDStoreDir</directive>)
and provide it, on next restart, to <module>mod_ssl</module>.
</p><p>
This happens while the server is already running. All other hosts will continue
to work as before. While a certificate is not available, requests for the managed
domain will be answered with a '503 Service Unavailable'.
</p>
</note>
<note><title>Prerequisites</title>
<p>
This module requires <module>mod_watchdog</module> to be loaded as well.
</p><p>
Certificate signup and renewal with Let's Encrypt requires your server to be
reachable on port 80 (http:) from the outside. The alternative method over
port 443 (https:) is currently disabled for security reasons (status from
2018-01-14).
</p><p>
The module will select from the methods offered by Let's Encrypt. If LE decides
at one point in the future, to re-enable it again, <module>mod_md</module> will
use it when suitable.
</p><p>
But for now, only the port 80 variant is available (termed "http-01"). Only
when LE can reach your server on port 80 will <module>mod_md</module> work for
you. For now, at least.
</p><p>
If you do not want to offer any sites on port 80 any more, you may leave it open
and redirect all requests to your https: sites instead. Use the
<directive module="mod_md">MDRequireHttps</directive> described below to do
that in a convenient fashion. This will continue to answer http: challenges
from Let's Encrypt.
</p>
</note>
</summary>
<directivesynopsis>
<name>MDomain</name>
<description>Define list of domain names that belong to one group.</description>
<syntax>MDomain <var>dns-name</var> [ <var>other-dns-name</var>... ] [auto|manual]</syntax>
<contextlist>
<context>server config</context>
</contextlist>
<usage>
<p>
All the names in the list are managed as one Managed Domain (MD).
<module>mod_md</module> will request one single certificate that is valid for all these names. This
directive uses the global settings (see other MD directives below). If you
need specific settings for one MD, use
the <directive module="mod_md" type="section">MDomainSet</directive>.
</p><p>
There are 2 additional settings that are necessary for a Managed Domain:
<directive module="core">ServerAdmin</directive>
and <directive module="mod_md">MDCertificateAgreement</directive>.
The mail address of <directive module="core">ServerAdmin</directive>
is used to register at the CA (Let's Encrypt by default).
The CA may use it to notify you about
changes in its service or status of your certificates.
</p><p>
The second setting, <directive module="mod_md">MDCertificateAgreement</directive>,
is the URL of the Terms of Service of the CA. When you configure the URL,
you confirm that you have read and agree to the terms described in the linked
document. Before you do that, the CA will not hand out certificates to you.
</p>
<example><title>Example</title>
<highlight language="config">
ServerAdmin mailto:admin@example.org
MDCertificateAgreement https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf
MDomain example.org www.example.org
<VirtualHost *:443>
ServerName example.org
DocumentRoot htdocs/root
SSLEngine on
</VirtualHost>
<VirtualHost *:443>
ServerName www.example.org
DocumentRoot htdocs/www
SSLEngine on
</VirtualHost>
</highlight>
</example>
<p>
There are two special names that you may use in this directive: 'manual'
and 'auto'. This determines if a Managed Domain shall have exactly the
name list as is configured ('manual') or offer more convenience. With 'auto'
all names of a virtual host are added to a MD. Conventiently, 'auto' is also
the default.
</p>
<example><title>Example</title>
<highlight language="config">
MDomain example.org
<VirtualHost *:443>
ServerName example.org
ServerAlias www.example.org
DocumentRoot htdocs/root
SSLEngine on
</VirtualHost>
MDomain example2.org auto
<VirtualHost *:443>
ServerName example2.org
ServerAlias www.example2.org
...
</VirtualHost>
</highlight>
</example>
<p>
In this example, the domain 'www.example.org' is automatically added to
the MD 'example.org'. Similarly for 'example2.org' where 'auto' is configured
explicitly. Whenever you add more ServerAlias names to this
virtual host, they will be added as well to the Managed Domain.
</p><p>
If you prefer to explicitly declare all the domain names, use 'manual' mode.
An error will be logged if the names do not match with the expected ones.
</p>
</usage>
</directivesynopsis>
<directivesynopsis type="section" idtype="section">
<name>MDomainSet</name>
<description>Container for directives applied to the same managed domains.</description>
<syntax><MDomainSet <var>dns-name</var> [ <var>other-dns-name</var>... ]>...</MDomainSet></syntax>
<contextlist>
<context>server config</context>
</contextlist>
<usage>
<p>
This directive allows you to define a Managed Domain (MD) with specific
settings, different from the global MD* ones. For example, you can have
such an MD use another CA then Let's Encrypt, have its unique renewal duration
etc.
</p>
<example><title>Example</title>
<highlight language="config">
<MDomainSet sandbox.example.org>
MDCertificateAuthority https://someotherca.com/ACME
MDCertificateAgreement https://someotherca.com/terms/v_1.02.pdf
</MDomainSet>
</highlight>
</example>
<p>This is a specialized version of <directive module="mod_md">MDomain</directive>,
it should be used only when a fine grained configuration is required.
<directive module="mod_md">MDomain</directive> is the suggested choice
for the general use case.</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>MDCertificateAgreement</name>
<description>The URL of the Terms-of-Service document, that the CA server requires you to accept.</description>
<syntax>MDCertificateAgreement <var>url-of-terms-of-service</var></syntax>
<contextlist>
<context>server config</context>
</contextlist>
<usage>
<p>When you use <module>mod_md</module> to obtain a certificate, you become a customer of the CA (e.g. Let's Encrypt). That means you need to read and agree to their Terms of Service,
so that you understand what they offer and what they might exclude or require from you.
<module>mod_md</module> cannot, by itself, agree to such a thing.
</p>
<p>In case of Let's Encrypt, their current <a href="https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf">Terms of Service are here</a>.
Those terms might (and probably will) change over time. So, the certificate renewal might require you to update this agreement URL.</p>
<example><title>Example</title>
<highlight language="config">
MDCertificateAgreement https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf
MDomain example.org www.example.org mail.example.org
</highlight>
</example>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>MDCertificateAuthority</name>
<description>The URL of the ACME Certificate Authority service.</description>
<syntax>MDCertificateAuthority <var>url</var></syntax>
<default>MDCertificateAuthority https://acme-v01.api.letsencrypt.org/directory</default>
<contextlist>
<context>server config</context>
</contextlist>
<usage>
<p>
The URL where the CA offers its service.
</p><p>
Let's Encrypt offers, right now, two such URLs. One for the real certificates and
one for testing (their staging area, at https://acme-staging.api.letsencrypt.org/directory).
In order to have <module>mod_md</module> use this testing service, configure your
server like this:
</p>
<example><title>LE Staging Setup</title>
<highlight language="config">
MDCertificateAuthority https://acme-staging.api.letsencrypt.org/directory
MDCertificateAgreement https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf
</highlight>
</example>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>MDCertificateProtocol</name>
<description>The protocol to use with the Certificate Authority.</description>
<syntax>MDCertificateProtocol <var>protocol</var></syntax>
<default>MDCertificateProtocol ACME</default>
<contextlist>
<context>server config</context>
</contextlist>
<usage>
<p>Specifies the protocol to use. Currently, only <code>ACME</code> is supported.</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>MDDriveMode</name>
<description>Control when it is allowed to obtain/renew certificates.</description>
<syntax>MDDriveMode always|auto|manual</syntax>
<default>MDDriveMode auto</default>
<contextlist>
<context>server config</context>
</contextlist>
<usage>
<p>In 'auto' mode, <module>mod_md</module> will <em>drive</em> a Managed Domain's
properties (e.g. certificate management) whenever necessary. When a MD is not used
in any virtual host, the module will do nothing. When a certificate is missing, it
will try to get one. When a certificate expires soon (see
<directive module="mod_md">MDRenewWindow</directive>), it will
renew it.
</p><p>
In 'manual' mode, it is your duty to do all this. The module will provide the existing
certificate to <module>mod_ssl</module>, if available. But it will not contact the CA for signup/renewal.
This can be useful in clustered setups where you want just one node to perform
the driving.
</p><p>
The third mode 'always' is like 'auto', with the difference that
<module>mod_md</module> will not check if the MD is actually used.
</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>MDHttpProxy</name>
<description>Define a proxy for outgoing connections.</description>
<syntax>MDHttpProxy <var>url</var></syntax>
<contextlist>
<context>server config</context>
</contextlist>
<usage>
<p>Use a http proxy to connect to the MDCertificateAuthority. Define this
if your webserver can only reach the internet with a forward proxy.
</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>MDMember</name>
<description>Additional hostname for the managed domain.</description>
<syntax>MDMember <var>hostname</var></syntax>
<contextlist>
<context>server config</context>
</contextlist>
<usage>
<p>
Instead of listing all dns names on the same line, you may use
<directive>MDMember</directive> to add such names
to a managed domain.
</p>
<example><title>Example</title>
<highlight language="config">
<MDomainSet example.org>
MDMember www.example.org
MDMember mail.example.org
</MDomainSet example.org>
</highlight>
</example>
<p>
If you use it in the global context, outside a specific MD, you can only
specify one value, 'auto' or 'manual' as the default for all other MDs. See
<directive module="mod_md">MDomain</directive> for a
description of these special values.
</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>MDMembers</name>
<description>Control if the alias domain names are automatically added.</description>
<syntax>MDMembers auto|manual</syntax>
<default>MDMembers auto</default>
<contextlist>
<context>server config</context>
</contextlist>
<usage>
<p>Defines if the <directive module="core">ServerName</directive> and
<directive module="core">ServerAlias</directive> values of a VirtualHost
are automatically added to the members of a Managed Domain or not.
</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>MDMustStaple</name>
<description>Control if new certificates carry the OCSP Must Staple flag.</description>
<syntax>MDMustStaple on|off</syntax>
<default>MDMustStaple off</default>
<contextlist>
<context>server config</context>
</contextlist>
<usage>
<p>Defines if newly requested certificate should have the OCSP Must Staple flag
set or not. If a certificate has this flag, the server is required to send a
OCSP stapling response to every client. This only works if you configure
<module>mod_ssl</module> to generate this (see <directive module="mod_ssl">SSLUseStapling</directive>
and friends).
</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>MDNotifyCmd</name>
<description>Run a program when Managed Domain are ready.</description>
<syntax>MDNotifyCmd <var>path</var> [ <var>args</var> ]</syntax>
<contextlist>
<context>server config</context>
</contextlist>
<usage>
<p>The configured executable is run when Managed Domains have signed up or
renewed their certificates. It is given the names of the processed MDs as
additional arguments (after the parameters specified here). It should
return status code 0 to indicate that it has run successfully.
</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>MDPortMap</name>
<description>Map external to internal ports for domain ownership verification.</description>
<syntax>MDPortMap <var>map1</var> [ <var>map2</var> ]</syntax>
<default>MDPortMap 80:80 443:443</default>
<contextlist>
<context>server config</context>
</contextlist>
<usage>
<p>
The ACME protocol provides two methods to verify domain ownership: one that uses
port 80 and one for port 443. If your server is not reachable by at least one
of the two, ACME will not work for you.
</p><p>
<module>mod_md</module> will look at your server configuration and try to figure
out which of those are available. Then it can select the proper ACME challenge
to create a certificate for your site.
</p><p>
However if you have some fancy port forwarding in place, your server may be
reachable from the Internet on port 443, but the local port that httpd uses is
another one. Your server might only listen on ports 5001 and 5002, but be reached
on ports 443 and 80. How should <module>mod_md</module> figure that one out?
</p><p>
With <directive>MDPortMap</directive> you can tell it which 'Internet port'
corresponds to which local port.
</p>
<example><title>Example</title>
<highlight language="config">
MDPortMap 80:- 443:5002
</highlight>
</example>
<p>
This example says that the server is not reachable on port 80 from the outside, but
local port 5002 is the one responding to https: requests.
</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>MDPrivateKeys</name>
<description>Set type and size of the private keys generated.</description>
<syntax>MDPrivateKeys <var>type</var> [ <var>params</var>... ]</syntax>
<default>MDPrivateKeys RSA 2048</default>
<contextlist>
<context>server config</context>
</contextlist>
<usage>
<p>
Defines what kind of private keys are generated for a managed domain and with
what parameters. The only supported type right now is 'RSA' and the only parameter
it takes is the number of bits used for the key.
</p><p>
The current (2017) recommendation is at least 2048 bits and a smaller number is
not accepted here. Higher numbers offer longer security, but are computationally more
expensive, e.g. increase the load on your server. That might or might not be an
issue for you.
</p><p>
Other key types will be defined in the future.
</p>
<example><title>Example</title>
<highlight language="config">
MDPrivateKeys RSA 3072
</highlight>
</example>
<p>
Please note that this setting only has an effect on new keys. Any existing
private key you have remains unaffected. Also, this only affects private keys
generated for certificates. ACME account keys are unaffected by this.
</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>MDRenewWindow</name>
<description>Control when a certificate will be renewed.</description>
<syntax>MDRenewWindow <var>duration</var></syntax>
<default>MDRenewWindow 33%</default>
<contextlist>
<context>server config</context>
</contextlist>
<usage>
<p>
If the validity of the certificate falls below duration, <module>mod_md</module>
will get a new signed certificate.
</p><p>
Normally, certificates are valid for around 90 days and <module>mod_md</module> will renew
them the earliest 33% of their complete lifetime before they expire (so for
90 days validity, 30 days before it expires). If you think this is not what
you need, you can specify either the exact time, as in:
</p>
<example><title>Example</title>
<highlight language="config">
# 21 days before expiry
MDRenewWindow 21d
# 30 seconds (might be close)
MDRenewWindow 30s
# 10% of the cert lifetime
MDRenewWindow 10%
</highlight>
</example>
<p>When in auto drive mode, the module will check every 12 hours at least
what the status of the managed domains is and if it needs to do something.
On errors, for example when the CA is unreachable, it will initially retry
after some seconds. Should that continue to fail, it will back off to a
maximum interval of hourly checks.
</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>MDRequireHttps</name>
<description>Redirects http: traffic to https: for Managed Domains.</description>
<syntax>MDRequireHttps off|temporary|permanent</syntax>
<default>MDRequireHttps off</default>
<contextlist>
<context>server config</context>
</contextlist>
<usage>
<p>This is a convenience directive to ease http: to https: migration of
your Managed Domains. With:
</p>
<example><title>Example</title>
<highlight language="config">
MDRequireHttps temporary
</highlight>
</example>
<p>you announce that you want all traffic via http: URLs to be redirected
to the https: ones, for now. This is safe and you can remove this again at
any time.
</p><p>
<strong>The following has consequences: </strong>if you want client to <strong>no longer</strong> use the
http: URLs, configure:
</p>
<example><title>Permanent (for at least half a year!)</title>
<highlight language="config">
MDRequireHttps permanent
</highlight>
</example>
<p>This does two things:
</p>
<ol>
<li>All request to the <code>http:</code> resources are redirected to the
same url with the <code>https:</code> scheme using the <code>301</code>
status code. This tells clients that this is intended to be forever and
the should update any links they have accordingly.
</li>
<li>All answers to <code>https:</code> requests will carry the header
<code>Strict-Transport-Security</code> with a life time of half a year.
This tells the browser that it <strong>never</strong> (for half a year) shall use <code>http:</code>
when talking to this domain name. Browsers will, after having seen this, refuse
to contact your unencrypted site. This prevents malicious middleware to
downgrade connections and listen/manipulate the traffic. Which is good. But
you cannot simply take it back again.
</li>
</ol>
<p>You can achieve the same with <module>mod_alias</module> and some
<directive module="mod_alias">Redirect</directive> configuration,
basically. If you do it yourself, please make sure to exclude the paths
/.well-known/* from your redirection, otherwise <module>mod_md</module>
might have trouble signing on new certificates.
</p>
<p>If you set this globally, it applies to all managed domains. If you want
it for a specific domain only, use:
</p>
<example><title>Example</title>
<highlight language="config">
<MDomainSet xxx.yyy>
MDRequireHttps temporary
</MDomainSet>
</highlight>
</example>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>MDStoreDir</name>
<description>Path on the local file system to store the Managed Domains data.</description>
<syntax>MDStoreDir path</syntax>
<default>MDStoreDir md</default>
<contextlist>
<context>server config</context>
</contextlist>
<usage>
<p>
Defines where on the local file system the Managed Domain data is stored. This is
an absolute path or interpreted relative to the server root. The default will create
a directory 'md' in your server root.
</p><p>
If you move this and have already data, be sure to move/copy the data first to
the new location, reconfigure and then restart the server. If you reconfigure
and restart first, the server will try to get new certificates that it thinks
are missing.
</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>MDCAChallenges</name>
<description>Type of ACME challenge used to prove domain ownership.</description>
<syntax>MDCAChallenges <var>name</var> [ <var>name</var> ... ]</syntax>
<default>MDCAChallenges tls-sni-01 http-01</default>
<contextlist>
<context>server config</context>
</contextlist>
<usage>
<p>
Sets challenge types and their execution order when proving domain ownership.
The names are protocol specific.
The current ACME protocol version implemented by Let's Encrypt defines two challenge
types that are supported by <module>mod_md</module>. By default, it will try
the one on port 443 when available.
</p>
</usage>
</directivesynopsis>
<directivesynopsis>
<name>MDBaseServer</name>
<description>Control if base server may be managed or only virtual hosts.</description>
<syntax>MDBaseServer on|off</syntax>
<default>MDBaseServer off</default>
<contextlist>
<context>server config</context>
</contextlist>
<usage>
<p>
Controls if the base server, the one outside all VirtualHosts should be managed by
<module>mod_md</module> or not. Default is to not do this, for the very reason that
it may have confusing side-effects. It is recommended that you have virtual hosts
for all managed domains and do not rely on the global, fallback server configuration.
</p>
</usage>
</directivesynopsis>
</modulesynopsis>
|