Adding a subdomain

It does not matter for nginx location and root statements :slight_smile:

2 Likes

Until it does - LOL
[I prepare for that day well in advance]

1 Like

The root statement does not behave different inside a location block than outside it.

I don't know why following your suggestion would be any more likely to avoid some future nginx bug or breaking change. There are no guarantees against such things.

Heck, even nginx's own docs show a location with a trailing slash and a root statement without one. In fact, all example root statements are shown without a trailing slash

Sets the root directory for requests. For example, with the following configuration

location /i/ {
root /data/w3;
}

https://nginx.org/en/docs/http/ngx_http_core_module.html#location

2 Likes

And that makes them futureproof?
I trust my instincts. Which say... Don't count on the software to always be smart enough to know what you meant and not do exactly as you say.
So, I say: Tell it clearly and exactly what you want it to do and don't ever test your luck with its' capacity to understand.

1 Like

The --nginx plugin does not setup or use a folder for the challenge tokens. When used as the authenticator it adds temp code to your nginx config to reply with the correct value directly in a return statement. Example shown below. It does this for initial cert and each renew.

If you use --nginx as your installer it will make permanent changes to your nginx config. It may do a variety of things such as setup a port 443 server block, add redirect to port 80 server block if requested, and other things (see Certbot docs). It does not make these changes during a renew command.

Doing just certbot --nginx uses it as both authenticator and installer. Using certbot certonly --nginx uses it only as authenticator.

Sample --nginx authenticator setting up your nginx for acme challenge
The "=" sign for a location statement has the highest priority for location block matching and selection.

server {rewrite ^(/.well-known/acme-challenge/.*) $1 break; # managed by Certbot

  listen 80;
  listen [::]:80;
  server_name example.com www.example.com;
  root /var/www/html;

  location = /.well-known/acme-challenge/MxkxRxkxzxkxgxHxvxkxOxpxkxVxkx8xkx4xFxExuxg 
    {default_type text/plain;
     return 200 MxkxRxkxzxkxgxHxvxkxOxpxkxVxkx8xkx4xFxExuxg.AwQwgwgwzwgwJwgw4wew3wrwxwiw-wpwvwqwxwBwswT;
    } # managed by Certbot
}
2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.