location root not working as described

Francis Daly francis at daoine.org
Sun Mar 21 00:14:42 UTC 2021


On Sat, Mar 20, 2021 at 03:08:03PM -0700, John Fowler wrote:

Hi there,

> Thank you for your suggestion, but I had tried using the alias as well and that did not work as advertised.  The following is the results of using the alias and “^~”.
> 
> I do see some odd behavior.
> 
> The following access snippet
> 2021/03/20 21:44:21 [error] 14#14: *7 open() "/var/www/certbottest.html" failed (2: No such file or directory), client: 10.0.0.2, server: cyva.lese-fowler.us, request: "GET /.well-known/acme-challenge/test.html HTTP/1.1", host: "cyva.lese-fowler.us"

"alias" does a straight textual swap of the part in "location" for the
part in "alias".

Either both should end in /, or neither should. (Usually, both should.)

> 2021/03/20 21:44:21 [error] 14#14: *7 open() "/var/www/certbottest.html" failed (2: No such file or directory), client: 10.0.0.2, server: cyva.lese-fowler.us, request: "GET /.well-known/acme-challenge/test.html HTTP/1.1", host: "cyva.lese-fowler.us"

> But I don’t know where the certbottest.html is coming from… 

The request is /.well-known/acme-challenge/test.html

>         location ^~ /.well-known/acme-challenge/ {
>             allow all;
>             alias /var/www/certbot;
>             try_files $uri =405;
>         }

The "location" part is "/.well-known/acme-challenge/". Replace that in
the request with the "alias" part of "/var/www/certbot", and you end up
with the configured filename of "/var/www/certbottest.html".

nginx is doing what it was told to do.

The previous suggestion was

> > Probably use "location ^~", but definitely use "alias /var/www/certbot/;".

Good luck with it,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list