At the moment, the Moodle 4 vhost template redirects all traffic to HTTPS, which interferes with the Let's encrypt certificate issue.
Since you can set HTTPS redirection inside Moodle or while installing it, I don't think it is needed in vhost template. This would also allow the installation Let's encrypt without any changes on vhost.
At the moment, the Moodle 4 vhost template redirects all traffic to HTTPS, which interferes with the Let's encrypt certificate issue.
Since you can set HTTPS redirection inside Moodle or while installing it, I don't think it is needed in vhost template. This would also allow the installation Let's encrypt without any changes on vhost.
I would suggest commenting out:
if ($scheme != "https") { rewrite ^ https://$host$uri permanent; }
Just as it is done in PrestShop vhost: https://github.com/cloudpanel-io/vhost-templates/blob/master/v2/PrestaShop/PrestaShop%201.7#L16
Also, this kind of redirect would also work:
set $redirect_to_https 0;
if ($scheme != "https") { set $redirect_to_https 1; }
if ($request_uri ~ ^/.well-known) { set $redirect_to_https 0; }
if ($redirect_to_https = 1) { return 301 https://$host$request_uri; }