Great Blog

07 Aug 2020

acme.sh/LetsEncrypt with 301 https redirect

This is very useful when you have everything redirected with NGiNX to HTTPS, but acme.sh/LetsEncrypt requires HTTP for verification.

server {
    listen 80;
    server_name DOMAIN.COM;

    root HTTP_ROOT;

    location ^~ /.well-known/acme-challenge/ {
        try_files $uri =404;
    }

    location / {
        return 301 https://DOMAIN.COM$request_uri;
    }
}