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

I know this is an old thread, but since Google finds it for many searches I thought I'd post my recent experience.

I found the configuration above didn't work for me, using the acmetool client and nginx. The primary problem was Acme was writing the challenge file to


whereas Nginx was looking in this directory


The combination of the acmetool logs and the Nginx logs made this obvious. Here are the two commands that helped parse the acmetool logs, from MrTen on this github page

acmetool --xlog.severity=debug > /tmp/dump 2>&1 
fgrep -v fdb: /tmp/dump | fgrep -v storageops: | less

The reason was found on Server Fault, on this question:

In case of the root directive, full path is appended to the root including the location part, whereas in case of the alias directive, only the portion of the path NOT including the location part is appended to the alias.

The nginx location block that worked for me is as below

location ^~ /.well-known/acme-challenge/ {
  alias /var/www/acme-challenge/;
1 Like