I've provided a full step by step tutorial on how to use Let's Encrypt with NGINX on my website.
The key parts are:
- The official client is only ok, and is really poor on Amazon Linux. I recommend a different client, ACME.
- Use this location for the webroot method, with my recommend client. Note that the requests are served over http, not https.
You don't need listeners in your https block at all, it's all done on https. This is only to prove you control the domain, it's not serving anything private or secret.
# Answer let's encrypt requests, but forward everything else to https
server {
listen 80;
server_name example.com www.example.com
access_log /var/log/nginx/access.log main;
# Let's Encrypt certificates with Acmetool
location /.well-known/acme-challenge/ {
alias /var/www/.well-known/acme-challenge/;
}
location / {
return 301 https://www.example.com$request_uri;
}
}
Full step by step guide linked above.