Report this

What is the reason for this report?

NGINX LetsEncrypt Cert location tag question

Posted on May 18, 2017
server {
        listen 80;
        listen [::]:80;
        server_name www.domain.com *.domain.com;

        return 301 http://domain.com;
}

server {
        listen 80;
        listen [::]:80;

        root /var/www/domain.com/html;

        index index.html index.htm index.nginx-debian.html;

        server_name domain.com;

        location / {
                try_files $uri $uri/ =404;
        }
}

The tutorial says to add to the SSL Server Block

        location ~ /.well-known {
                allow all;
        }

so i updated mine to be:

server {
        listen 80;
        listen [::]:80;
        server_name www.domain.com *.domain.com;

        return 301 http://domain.com;
}

server {
        listen 80;
        listen [::]:80;

        root /var/www/domain.com/html;

        index index.html index.htm index.nginx-debian.html;

        server_name domain.com;

        location ~ /.well-known {
                allow all;
        }

        location / {
                try_files $uri $uri/ =404;
        }
}

I was just wondering if this is the proper way to do it or if there is a better way to do it?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

@ariziragoran

If you’re using the web root option, that’s the method you’ll need to use.

The other option would be to use the certonly option, though you’d need to stop NGINX, run the certificate command, and then start NGINX since the Let’s Encrypt (now CertBot) application needs to access ports 80 and 443.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.