aboutsummaryrefslogtreecommitdiffstats
path: root/roles/web/templates/sites/00-acme-httpredirect.conf.j2
blob: a4b59a8d3cd88cc114cd37d00dd19ea8ad5ba21f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#
# Nignx/sites: 00-acme-httpredirect.conf
# Provide ACME challenges to issue certificate from Let's Encrypt,
# and redirect HTTP to HTTPs.
#
# Aaron LI
#

server {
    listen       80 default_server;
    listen  [::]:80 default_server;
    server_name  _;

    location ^~ /.well-known/acme-challenge/ {
        default_type  text/plain;
        root          {{ web.acme_webroot }};
    }
    location = /.well-known/acme-challenge/ {
        return  404;
    }

    # Redirect to HTTPS
    location / {
        return  301  https://$host$request_uri;
    }
}