Closed
Description
Hi this is related to Letsencrypt manual authenticator mode with the ACME challenge file having a dot prefix certbot/certbot#730. This can be blocked with 403 Forbidden access by some Nginx configurations which block dot prefix files/folders from web access by default.
i.e.
location ~ /\. { access_log off; log_not_found off; deny all; }
For a workaround for me, I had to add this to my Nginx vhost
location ~ /.well-known {
location ~ /.well-known/acme-challenge/(.*) {
more_set_headers "Content-Type: application/jose+json";
}
}
Probably need to document this for folks as to requirements needed for Nginx to allow dot prefix file for .well-known
requests
not sure if you just add a curl check of the ACME challenge file for the status code so if it's anything other than 200 status, you can show a more detailed explanation ? i.e. if it's 403 status for the curl header check, say
ensure nginx vhost allows dot prefix directory access to /.well-known
Activity
riobard commentedon Jan 4, 2016
You should use the following in nginx config
mnpenner commentedon Mar 6, 2016
Thank you @riobard. I was trying with
But that didn't do it... I guess nginx keeps processing the other restrictions. Yours seems to do the trick though.
kb- commentedon Apr 8, 2016
Hi, my free webhost is blocking the " .well-known too", the dot being the problem. They only give very limited control with htaccess files and the apache configuration is of course locked... So I can't find a workaround.
Is there a way to change the challenge URL to something else who doesn't contain a dot?
augnustin commentedon Apr 20, 2016
After some struggle, here's my working config:
wturrell commentedon May 30, 2016
Despite plenty of servers/configs where this works fine…
on one where
/.well-known
is an alias, I have to add an^
otherwise I get 403 Forbidden. (I can't understand why – I commented out all the other location blocks in turn, none of which match anyway, and it made no difference…)rowanthorpe commentedon Jul 8, 2016
The reason @riobard's version works is because of the order and manner in which nginx works through the location matches. I personally find the way it is documented at nginx.org adds an unnecessary layer of temporal convolution (unless there is some nuance that I have missed when reordering the guts of points 3 and 4 below), so this is my version:
location = XXX {}
)location ^~ XXX {}
)location ~ XXX {}
), or case-insensitive regex-matches (withlocation ~* XXX {}
)location XXX {}
)The three biggest sources of confusion I have seen relevant to these kind of issues with Nginx configs are:
^~
does not signify a form of regex-match despite including the~
symbol. This surprises people coming from languages like Perl, etc.root
andalias
directives, which sometimes become "action at a distance" gotchasI find the following example useful (good to leave all of
/.well-known
open, as acme isn't the only protocol to use that directory), and of course add things like @centminmod's added header for an acme-challenge sub-match within the .well-known block if you want:Add preferential prefix for NGINX.
cpu commentedon Apr 4, 2017
This repository is deprecated & un-maintained. Closing this issue. If applicable, please move discussion to the replacement IETF owned repo and the mailing list.
helok commentedon Apr 29, 2017
location ^~ /.well-known/acme-challenge/ {
allow all;
default_type "text/plain";
}