Doing domain validation in this way is the only way to obtain wildcard certificates from Let’s Encrypt

install certbot-auto

curl -O https://dl.eff.org/certbot-auto

modify certbot-auto

# find the following line
elif [ -f /etc/redhat-release ]; then
# replace that line with the following line
elif [ -f /etc/redhat-release ] || grep 'cpe:.*:amazon_linux:2' /etc/os-release > /dev/null 2>&1; then

move certbot-auto

mv certbot-auto /usr/local/bin/certbot-auto

switch to root user (NOTE - keeps the $PATH)

sudo su -

generate certificate for “*.marcuschiu.com” and “marcuschiu.com”

certbot-auto certonly --manual --preferred-challenges=dns --email marcuschiu9@gmail.com --server https://acme-v02.api.letsencrypt.org/directory --agree-tos -d "*.marcuschiu.com" -d "marcuschiu.com" --debug

once this process is finished we get 2 files:

  • /etc/letsencrypt/live/marcuschiu.com/fullchain.pem
  • /etc/letsencrypt/live/marcuschiu.com/privkey.pem

use this in Nginx like so below

ssl_certificate     /etc/letsencrypt/live/marcuschiu.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/marcuschiu.com/privkey.pem;

server {
	listen 443 ssl;
	server_name marcuschiu.com www.marcuschiu.com;
	...
}

server {
	listen 443 ssl;
	server_name confluence.marcuschiu.com;
    ...
}

# more https servers

# redirect http to https
server {
	listen 80 default_server;
	server_name _;
    return 301 https://$host$request_uri;
}