How-to: Nginx configuration to enable ACME Challenge support on all HTTP virtual hosts

I wonder if you could just use both root and alias with the location { } and cover all bases!

location ^~ /.well-known/acme-challenge/ {
 default_type "text/plain";
 alias /var/www/acme-challenge/;
 root /var/www/acme-challenge/;
}

Well that was a FAIL:
as per nginx -t
nginx: [emerg] “root” directive is duplicate, “alias” directive was specified earlier in /etc/nginx/conf.d/my.conf
And reversing the alias/root order is also a FAIL:
nginx: [emerg] “alias” directive is duplicate, “root” directive was specified earlier in /etc/nginx/conf.d/my.conf

So it seems that root and alias are synonymous now.

1 Like