Let's Encrypt in a cluster#
Let's Encrypt gives a server a certificate for free and renews it every few weeks, by itself. On one server that needs no thought. With several servers behind one name it needs two things to be right: the proof that the name is yours must succeed whichever server is asked, and the new certificate must reach every server.
The certificate itself is set up with the Let's Encrypt plugin, in Preferences, Plugins. This page is about what a cluster adds.
The two problems#
1. The proof. To issue or renew, Let's Encrypt checks that you control the name. With the usual kind of check it calls the name on port 80 or 443 and expects a certain answer. Behind a load balancer that call lands on any server, and only the server that asked for the certificate knows the answer.
2. The spread. One server gets the new certificate. Users land on all of them. A server with the old certificate, or none, shows a warning.
The spread: Replicate?#
The plugin has a switch, Replicate?. With it, the server that obtained the certificate sends the key store to every other server of the cluster. Each one writes the file, loads it, passes it to its DMZs, and starts its secure ports again with the new certificate.
Turn it on. That settles the second problem.
For it to work, the key store must have the same path on every server, since the path is part of the replicated settings.
The proof: which kind#
The plugin offers four kinds of proof. In a cluster they differ:
| Kind | How the name is proven | In a cluster |
|---|---|---|
| http-01 | Let's Encrypt fetches a file from the name on port 80 | the request can land on any server: the answer must be on all of them, or the balancer must send that one path to the server that asked |
| tls-alpn-01 | Let's Encrypt connects to the name on port 443 and expects a special certificate | the same problem, and the balancer must pass TLS through untouched |
| dns-01 | a record in the name's DNS zone | no problem: nothing is asked of any server. The plugin sets the record through the DNS provider. |
| dns-persist-01 | a DNS record that is set once and stays | no problem either, and nothing has to change at each renewal |
So, with several servers behind one name: use a DNS kind if your DNS provider allows it. It also works for servers that the internet cannot reach at all, and for wildcard names.
If it has to be http-01, the simple arrangement is to let one server do the renewing and have the balancer send requests for /.well-known/acme-challenge/ to that server.
Who renews#
Set the plugin up on one server to obtain and renew, with Update the certificate automatically and Replicate? on. The other servers receive.
If every server renewed by itself, each would ask Let's Encrypt for its own certificate for the same name. That works until the limit on certificates per name is reached, and it gives users a different certificate on each server.
The plugin's settings replicate with the preferences. The renewing itself is done by the server that holds the schedule: in a cluster, the one that runs scheduled work. See Jobs in a cluster.
Servers with DMZs#
The name users call points at the DMZs, so the certificate is for the DMZs' ports. But a DMZ keeps nothing, and its certificate comes from its server.
- Set the plugin up on the inner server, never on a DMZ.
- In the plugin, the Server Instance says for which instance the certificate is: choose the DMZ. One plugin entry per DMZ instance whose name needs a certificate.
- With http-01 or tls-alpn-01, Let's Encrypt's call arrives at the DMZ, which passes it inward like any request.
- The server sends the new certificate to its DMZs by itself.
For a certificate of the inner servers' own names, leave Server Instance empty: it then means the server itself. A check that is meant for the server and is pointed at a DMZ fails.
One certificate for several names#
When the servers are also reached by their own names (files1.example.com, files2.example.com) beside the shared one, put all names into one certificate. Each server then shows a certificate that fits, whichever name was called.
Checking it#
- Run the plugin once by hand and read its answer.
- Look at the certificate each server shows, by its own address: the same serial number and end date on all.
- Look again after the first renewal by itself, about two months later. A renewal that works on the first server and does not spread is the usual failure, and it shows only then.
The report Expiry calendar in the Reports app lists certificates that end soon, and the Settings scorecard checks for expired ones.
Things to know#
- Port 80 must be reachable from the internet for http-01, at the shared name. Many firewalls close it.
- Renewal happens long before the end, so one failed try does no harm. Several in a row do: have the plugin's failures reach somebody, through the alert for failed mail or the server log.
- Certificates from another authority, bought or from your own, are spread the same way: the key store is a file named in the settings. Put the same file on every server under the same path.
- A node's own key is something else. The keys by which the servers of a cluster know each other are not certificates of this kind and never run out: Trust between servers.
- Nothing here was run for this page. No certificate was obtained on the test server. The switches are those of the plugin's form; the rest follows the CrushFTP 11 page as a checklist.