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