This module manages common properties of domains for one or more virtual hosts. Specifically it can use the ACME protocol (RFC Draft) 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 Let's Encrypt.
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.
Simple configuration example:
This setup will, on server start, contact
Let's Encrypt
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
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'.
This module requires
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).
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,
But for now, only the port 80 variant is available (termed "http-01"). Only
when LE can reach your server on port 80 will
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
All the names in the list are managed as one Managed Domain (MD).
mod_md 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
There are 2 additional settings that are necessary for a Managed Domain:
The second setting,
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.
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 Manged Domain.
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.
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.
This is a specialized version of
When you use
In case of Let's Encrypt, their current Terms of Service are here. Those terms might (and probably will) change over time. So, the certificate renewal might require you to update this agreement URL.
The URL where the CA offers its service.
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
Specifies the protocol to use. Currently, only ACME
is supported.
In 'auto' mode,
In 'manual' mode, it is your duty to do all this. The module will provide the existing certificate to mod_ssl, 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.
The third mode 'always' is like 'auto', with the difference that
Use a http proxy to connect to the MDCertificateAuthority. Define this if your webserver can only reach the internet with a forward proxy.
Instead of listing all dns names on the same line, you may use
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
Defines if the
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
mod_ssl to generate this (see
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 arguments. It should return status code 0 to indicate that it has run successfully.
The ACME protocol provides two method 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.
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
With MDPortMap you can tell it which 'Internet port' corresponds to which local port.
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.
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.
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.
Other key types will be defined in the future.
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.
If the validity of the certificate falls below duration, mod_md will get a new signed certificate.
Normally, certificates are valid for around 90 days and mod_md 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:
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.
This is a convenience directive to ease http: to https: migration of your Managed Domains. With:
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.
The following has consequences: if you want client to no longer use the http: URLs, configure:
This does two things:
http:
resources are redirected to the
same url with the https:
scheme using the 301
status code. This tells clients that this is intended to be forever and
the should update any links they have accordingly.
https:
requests will carry the header
Strict-Transport-Security
with a life time of half a year.
This tells the browser that it never (for half a year) shall use http:
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.
You can achieve the same with mod_alias and some Redirect configuration, basically. If you do it yourself, please make sure to exclude the paths /.well-known/* from your redirection, otherwise mod_md might have trouble signing on new certificates.
If you set this globally, it applies to all managed domains. If you want it for a specific domain only, use:
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.
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.
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
Controls if the base server, the one outside all VirtualHosts should be managed by