Nginx ACME Challenge Selection
From a domain name to a trusted certificate
A public certificate authority (CA) checks control of the requested identifiers before signing a certificate. ACME (Automatic Certificate Management Environment) is a protocol for automating that process. Let’s Encrypt is a CA; Certbot is an ACME client; Nginx serves traffic. They have separate responsibilities. An ACME account key authenticates protocol requests, while a certificate private key authenticates the TLS service. Protect both. The core lab uses a fictional .test name and never contacts a CA.
Client -> CA: create order for owned domainCA -> client: authorization challengeClient: publish challenge responseCA: validate controlClient -> CA: finalize using certificate signing requestCA -> client: issued certificate chainThe order is not the certificate. If validation or finalization fails, the client must diagnose the error before retrying. Domain validation does not establish that a business is reputable.
Pick the challenge that matches the deployment
HTTP-01 requires public reachability on TCP port 80 and a challenge response at a special path. It cannot authorize a wildcard name. DNS-01 publishes a derived value in a TXT record at _acme-challenge followed by the name; it supports wildcard names and does not require public HTTP reachability. Wait for authoritative DNS propagation and remove obsolete TXT values. TLS-ALPN-01 uses a special TLS validation handshake on TCP port 443; client and listener must explicitly support it. An ordinary HTTPS certificate response is not enough.
_acme-challenge.example.com. 300 IN TXT "mock-derived-value"For a private service needing a wildcard certificate, DNS-01 is a plausible choice if the organization controls public DNS. Prefer narrowly scoped DNS credentials or delegated validation zones; never give the web process broad DNS administrator access. For multiple HTTP frontends, ensure every eligible validation destination can return the same challenge response.
Reserve a dedicated challenge location
server { listen 80; server_name example.com; location ^~ /.well-known/acme-challenge/ { root /var/www/acme; default_type text/plain; try_files $uri =404; } location / { return 301 https://example.com$request_uri; }}The mock token file belongs under /var/www/acme/.well-known/acme-challenge/. The root directive appends the URI. The ^~ prefix avoids ordinary regex matches at this server level. Put the redirect in location / rather than at server scope, because a server-level return can run before location processing. Missing challenge files should return 404, not the SPA home page. Never serve the ACME account directory or private keys.
certbot certonly --webroot -w /var/www/acme -d example.comThe client places validation files in that webroot. The command can communicate with a public CA, create account data and write certificates. Replace the reserved example name only in an explicitly approved real-domain exercise. A Certbot Nginx installer can modify configuration; review changes first. Other choices include a reviewed DNS plugin or a separately installed Nginx ACME module; the presence of Nginx alone does not establish module support.
Let’s Encrypt staging issues test certificates that ordinary browsers do not trust. It has separate accounts and limits. Production quotas and authorization failure limits apply; consult the current CA policy and respect Retry-After. The lab uses mock data instead of either endpoint.
Practice
Choose a challenge for a public single-site server, an internal wildcard service and a 443-only validation-capable endpoint. Then predict the status and body for the existing and missing mock token in the chapter lab.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Nginx ACME Challenge Selection
Choose a domain validation method and route HTTP challenges without disrupting the rest of a website.
Which challenge can authorize a wildcard DNS name?
Which public port is required for HTTP-01?
Where does the token live with root /var/www/acme?
Why keep return in location /?
What does a staging certificate demonstrate?