|
| 1 | +############################################################################# |
| 2 | +# Configuration file for Let's Encrypt ACME Challenge location |
| 3 | +# This file is already included in listen_xxx.conf files. |
| 4 | +# Do NOT include it separately! |
| 5 | +############################################################################# |
| 6 | +# |
| 7 | +# This config enables to access /.well-known/acme-challenge/xxxxxxxxxxx |
| 8 | +# on all our sites (HTTP), including all subdomains. |
| 9 | +# This is required by ACME Challenge (webroot authentication). |
| 10 | +# You can check that this location is working by placing ping.txt here: |
| 11 | +# /var/www/letsencrypt/.well-known/acme-challenge/ping.txt |
| 12 | +# And pointing your browser to: |
| 13 | +# http://xxx.domain.tld/.well-known/acme-challenge/ping.txt |
| 14 | +# |
| 15 | +# Sources: |
| 16 | +# https://community.letsencrypt.org/t/howto-easy-cert-generation-and-renewal-with-nginx/3491 |
| 17 | +# |
| 18 | +############################################################################# |
| 19 | + |
| 20 | +# Rule for legitimate ACME Challenge requests (like /.well-known/acme-challenge/xxxxxxxxx) |
| 21 | +# We use ^~ here, so that we don't check other regexes (for speed-up). We actually MUST cancel |
| 22 | +# other regex checks, because in our other config files have regex rule that denies access to files with dotted names. |
| 23 | +location ^~ /.well-known/acme-challenge/ { |
| 24 | + |
| 25 | + # Set correct content type. According to this: |
| 26 | + # https://community.letsencrypt.org/t/using-the-webroot-domain-verification-method/1445/29 |
| 27 | + # Current specification requires "text/plain" or no content header at all. |
| 28 | + # It seems that "text/plain" is a safe option. |
| 29 | + default_type "text/plain"; |
| 30 | + |
| 31 | + # This directory must be the same as in /etc/letsencrypt/cli.ini |
| 32 | + # as "webroot-path" parameter. Also don't forget to set "authenticator" parameter |
| 33 | + # there to "webroot". |
| 34 | + # Do NOT use alias, use root! Target directory is located here: |
| 35 | + # /var/www/common/letsencrypt/.well-known/acme-challenge/ |
| 36 | + root /var/www/letsencrypt; |
| 37 | + autoindex on; |
| 38 | +} |
| 39 | + |
| 40 | +# Hide /acme-challenge subdirectory and return 404 on all requests. |
| 41 | +# It is somewhat more secure than letting Nginx return 403. |
| 42 | +# Ending slash is important! |
| 43 | +location = /.well-known/acme-challenge/ { |
| 44 | + return 404; |
| 45 | +} |
0 commit comments