This module manages common properties of domains for one or more virtual hosts. Its main feature is the use of the ACME protocol (RFC 8555) to automate certificate provisioning. Certificates will be renewed by the module ahead of their expiration to account for disruption in internet services. There are ways to monitor the status of all Managed Domains and configurations that will run your own notification commands on renewal, expiration and errors.
The default ACME Certificate Authority is Let's Encrypt, but it is possible to configure another CA that supports the protocol.
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 sign-up 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, mod_md will use it when suitable.
But for now, only the port 80 variant is available (termed "http-01"). Only when LE can reach your server on port 80 will mod_md work for you. For now, at least.
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
Wildcard certificates are possible with version 2.x of `mod_md``. But they are not straight-forward. Let's Encrypt requires the `dns-01` challenge verification for those. No other is considered good enough.
The difficulty here is that Apache cannot do that on its own. (which is also a security benefit, since corrupting a web server or the communication path to it is the scenario `dns-01` protects against). As the name implies, `dns-01` requires you to show some specific DNS records for your domain that contain some challenge data. So you need to _write_ your domain's DNS records.
If you know how to do that, you can integrated this with `mod_md`. Let's say you have a script for that in `/usr/bin/acme-setup-dns` you configure Apache with:
and Apache will call this script when it needs to setup/teardown a DNS challenge record for a domain.
Assuming you want a certificate for `*.mydomain.com`, mod_md will call:
and afterwards it will call
Apache has a standard module for monitoring:
You see all your MDs listed alphabetically, the domain names they contain, an overall status, expiration times and specific settings. The settings show your selection of renewal times (or the default), the CA that is used, etc.
The 'Renewal' column will show activity and error descriptions for certificate renewals. This should make life easier for people to find out if everything is all right or what went wrong.
If there is an error with an MD it will be shown here as well. This let's you assess problems without digging through your server logs.
There is also a new 'md-status' handler available to give you the MD information from 'server-status' in JSON format. You configure it as
on your server. As with 'server-status' you will want to add authorization for this.
If you just want to check the JSON status of a specific domain, simply append that to your status url:
This JSON status also shows a log of activities when domains are renewed:
You will also find this information in the file `job.json` in your staging and, when activated, domains directory. This allows you to inspect these at any later point in time as well.
In addition, there is
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. Conveniently, '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 Managed 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 is the directive
This allows you to configure an MD that uses another Certificate Authority, have other renewal requirements, etc.
A common use case is to configure https: requirements separately for your domains.
When you use mod_md 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. mod_md cannot, by itself, agree to such a thing.
The URL where the CA offers its service.
Let's Encrypt offers, right now, four such URLs. Two for the own legacy version of the ACME protocol, commonly named ACMEv1. And two for the RFC 8555 version, named ACMEv2.
Each version has 2 endpoints, as their is a production endpoint and a "staging" endpoint for testing. The testing endpoint works the same, but will not give you certificates recognized by browsers. However, it also has very relaxed rate limits. This allows testing of the service repeatedly without you blocking yourself.
Specifies the protocol to use. Currently, only ACME is supported.
This directive exists for backward compatibility as the old name for
In the default 'auto' mode, the module will do what makes most sense of each Managed Domain. For a domain without any certificates, it will obtain them from the Certificate Authority.
However, if you have defined an MD that is not used by any of Apache's
VirtualHosts, it will not bother. And for MDs with static certificate
files (see
You can override this default in either way. If you specify 'always', the module will renew certificates for an MD, irregardless if the domains are in use or if there are static files.
For the opposite effect, configure 'manual' and no renewal will be attempted.
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
The configured executable is run when a Managed Domain has signed up or renewed its certificate. It is given the name of the processed MD as additional arguments (after the parameters specified here). It should return status code 0 to indicate that it has run successfully.
The ACME protocol provides two methods to verify domain ownership via
HTTP: one that uses 'http:' urls (port 80) and one for 'https:' urls
(port 443). If your server is not reachable by at least one
of the two, ACME may only work by configuring your DNS server,
see
On most public facing servers, 'http:' arrives on port 80 and 'https:' on port 443. The module checks the ports your Apache server is listening on and assumes those are available. This means that when your server does not listen on port 80, it assumes that 'http:' requests from the internet will not work.
This is a good guess, but it may be wrong. For example, your Apache might listen to port 80, but your firewall might block it. 'http:' is only available in your intranet. So, the module will falsely assume that Let's Encrypt can use 'http:' challenges with your server. This will then fail, because your firewall will drop those.
The above example shows how you can specify that 'http:' requests from the internet will never arrive. In addition it says that 'https:' requests will arrive on local port 8433.
This is necessary if you have 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 8443 and 8000, but be reached on ports 443 and 80 (from the internet).
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
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 three challenge types that are supported by mod_md. By default, it will try the one on port 443 when available.
Controls if the base server, the one outside all VirtualHosts should be managed by mod_md or not. By default, it will not. 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.
This is used inside a
This is that equivalent of the mod_ssl
If you want to migrate an existing domain, using static files, to
automated Let's Encrypt certificates, for one. You define the
This will give you the same as before, with maybe less repeating lines
in your configuration. Then you can add
Another use case is that you renew your Let's Encrypt certificates with another ACME clients, for example the excellent certbot. Then let your MDs point to the files from certbot and have both working together.
This is used inside a
This is that equivalent of the mod_ssl
When enabled, a resources is available in Managed Domains at 'https://domain/.httpd/certificate-status' that returns a JSON document list key properties of the current and of a renewed certificate - when available.
Define a program to be called when the `dns-01` challenge needs to be setup/torn down. The program is given the argument `setup` or `teardown` followed by the domain name. For `setup` the challenge content is additionally given.
You do not need to specify this, as long as a 'http:' or 'https:' challenge method is possible. However, Let's Encrypt makes 'dns-01' the only challenge available for wildcard certificates. If you require one of those, you need to configure this.
See the section about wildcard certificates above for more details.
This command gets called when one of the following events happen for a Managed Domain: "renewed", "expiring", "errored". The command may be invoked for more than these in the future and ignore events it is not prepared to handle.
This is the more flexible companion to
The program should not block, as the module will wait for it to finish. A return code other than 0 is regarded as an error.
'errored' is no immediate cause for concern since renewal is attempted early enough to allow the internet to come back.
'expiring' should be taken serious. It is issued when the
See
The modules checks the remaining lifetime of certificates and invokes
It also applies to Managed Domains with static certificate files (
see
Apaches 'server-status' handler allows you configure a resource to monitor what is going on. This includes now a section listing all Managed Domains with the DNS names, renewal status, lifetimes and main properties.
You can switch that off using this directive.