I use the “return 300” to go from http to https. But if I do not comment this line, the letsencrypt command does not work I can deal with it for the first time, but I get the same problem with the renew…

If your HTTPS configuration is correct, there should not be a problem. Unfortunately, you’re just saying “the … command does not work” without actually telling us the error et cetera. Please give us the full output of the command you used.

Please post your real domain. Obscuring it is super detrimental to the process of helping you. You can always edit it out later.

thierryler:

return 300 https://www.mywebsite.fr$request_uri;

I think you need should wrap this in location block:

location / {
return 301 https://www.mywebsite.fr$request_uri;
}

Because putting it in the server scope directly prevents that other location block from applying. Hypothetically (I can’t test it because of obscured domain) if you then had an nginx location block in your HTTPS server that blocked access to “dotfiles”, that could explain your current symptoms.

Yes, that can be a way to go as well. The reason I did not suggest it is that OP did not post the full virtual host, and the ordering of regex-based locations with nginx can be very subtle. Potentially, that location could get overriden by a dotfile location.

So I felt the safer way was to avoid the redirect entirely and complete the challenge on port 80.

Osiris:

I don’t think the HTTP to HTTPS redirect should be outside the HTTP server scope.

It definitely should be, if you want to have any other location blocks inside the server scope.

The following certs are not due for renewal yet:
/etc/letsencrypt/live/sgp4.fr/fullchain.pem expires on 2019-10-11 (skipped)
/etc/letsencrypt/live/www.sgp4.fr/fullchain.pem expires on 2019-10-11 (skipped)