nginx-le-root.conf 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # Originally from:
  2. # https://community.letsencrypt.org/t/how-to-nginx-configuration-to-enable-acme-challenge-support-on-all-http-virtual-hosts/5622
  3. #############################################################################
  4. # Configuration file for Let's Encrypt ACME Challenge location
  5. # This file is already included in listen_xxx.conf files.
  6. # Do NOT include it separately!
  7. #############################################################################
  8. #
  9. # This config enables to access /.well-known/acme-challenge/xxxxxxxxxxx
  10. # on all our sites (HTTP), including all subdomains.
  11. # This is required by ACME Challenge (webroot authentication).
  12. # You can check that this location is working by placing ping.txt here:
  13. # /var/www/letsencrypt/.well-known/acme-challenge/ping.txt
  14. # And pointing your browser to:
  15. # http://xxx.domain.tld/.well-known/acme-challenge/ping.txt
  16. #
  17. # Sources:
  18. # https://community.letsencrypt.org/t/howto-easy-cert-generation-and-renewal-with-nginx/3491
  19. #
  20. #############################################################################
  21. # Rule for legitimate ACME Challenge requests (like /.well-known/acme-challenge/xxxxxxxxx)
  22. # We use ^~ here, so that we don't check other regexes (for speed-up). We actually MUST cancel
  23. # other regex checks, because in our other config files have regex rule that denies access to files with dotted names.
  24. location ^~ /.well-known/acme-challenge/ {
  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. # This directory must be the same as in /etc/letsencrypt/cli.ini
  31. # as "webroot-path" parameter. Also don't forget to set "authenticator" parameter
  32. # there to "webroot".
  33. # Do NOT use alias, use root! Target directory is located here:
  34. # /var/www/common/letsencrypt/.well-known/acme-challenge/
  35. root /var/www/letsencrypt;
  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. }