location root not working as described

Francis Daly francis at daoine.org
Fri Mar 19 23:17:52 UTC 2021


On Fri, Mar 19, 2021 at 03:01:19PM -0700, John Fowler wrote:

Hi there,

> I have nginx running in a docker container and configured to use let’s encrypt for certificates services. 
> The location redirect to /var/www/certbot from /.well-known/acme-challenge does not seem to work.  

Compare http://nginx.org/r/root and http://nginx.org/r/alias

You probably want alias.

> root at b15f5f234fbb:/var/log/nginx# cd /var/www/certbot
> root at b15f5f234fbb:/var/www/certbot# ls -l
> total 12
> -rw-r--r-- 1 root root 1727 Mar 18 03:22 index.html
> -rw-r--r-- 1 root root 1531 Mar 18 03:23 test.html
> -rw-r--r-- 1 root root 1533 Mar  9 02:59 test2.html
> root at b15f5f234fbb:/var/www/certbot# 

> 2021/03/19 21:28:27 [error] 15#15: *1 open() "/var/www/certbot/.well-known/acme-challenge/index.html" failed (2: No such file or directory), client: 10.0.0.2, server: cyva.lese-fowler.us, request: "GET /.well-known/acme-challenge/index.html HTTP/1.1", host: "cyva.lese-fowler.us"

That GET request trying to open that file, is because "root" was used.

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

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

Cheers,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list