Browse Source

Added nginx config

Brielle Bruns 2 years ago
parent
commit
ee2f2daee0
1 changed files with 46 additions and 0 deletions
  1. 46
    0
      nginx-le-root.conf

+ 46
- 0
nginx-le-root.conf View File

@@ -0,0 +1,46 @@
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
+
22
+# Rule for legitimate ACME Challenge requests (like /.well-known/acme-challenge/xxxxxxxxx)
23
+# We use ^~ here, so that we don't check other regexes (for speed-up). We actually MUST cancel
24
+# other regex checks, because in our other config files have regex rule that denies access to files with dotted names.
25
+location ^~ /.well-known/acme-challenge/ {
26
+
27
+    # Set correct content type. According to this:
28
+    # https://community.letsencrypt.org/t/using-the-webroot-domain-verification-method/1445/29
29
+    # Current specification requires "text/plain" or no content header at all.
30
+    # It seems that "text/plain" is a safe option.
31
+    default_type "text/plain";
32
+
33
+    # This directory must be the same as in /etc/letsencrypt/cli.ini
34
+    # as "webroot-path" parameter. Also don't forget to set "authenticator" parameter
35
+    # there to "webroot".
36
+    # Do NOT use alias, use root! Target directory is located here:
37
+    # /var/www/common/letsencrypt/.well-known/acme-challenge/
38
+    root         /var/www/letsencrypt;
39
+}
40
+
41
+# Hide /acme-challenge subdirectory and return 404 on all requests.
42
+# It is somewhat more secure than letting Nginx return 403.
43
+# Ending slash is important!
44
+location = /.well-known/acme-challenge/ {
45
+    return 404;
46
+}