Good morning everyone...
I am stuck on creating certificates via certbot:
After running : sudo certbot certonly --webroot -w ./data/certbot/www -d prostatecanceratlas.org -d www.prostatecanceratlas.org
I see that certbot returns a 404 error:
Certbot failed to authenticate some domains (authenticator: webroot). The certificate authority reported these problems:
Domain: prostatecanceratlas.org
Type: unauthorized
Detail: 2a01:4f8:d0a:27bd::1234: Invalid response from http://prostatecanceratlas.org/.well-known/acme-challenge/yiQBPmOxSiyjrR_E6dno1kMbebpyXCthfAJt-WM7Aok: 404
Domain: www.prostatecanceratlas.org
Type: unauthorized
Detail: 2a01:4f8:d0a:27bd::1234: Invalid response from http://www.prostatecanceratlas.org/.well-known/acme-challenge/uVAq_RKl826CGcx18i6CGBdZWuGyqYVVGikmr5xtY60: 404
Hint: The certificate authority failed to download the temporary challenge files created by Certbot. Make sure that the listed domains serve their contents from the --webroot/-w path provided and that the created files can be downloaded from the Internet.
I don't know how to solve this problem....
I will leave you my nginx.config:
server {
listen 80;
server_name prostatecanceratlas.org/;
server_tokens off;
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name prostatecanceratlas.org;
ssl_certificate /etc/letsencrypt/live/prostatecanceratlas.org-0001/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/prostatecanceratlas.org-0001/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
sendfile on;
default_type application/octet-stream;
gzip on;
gzip_http_version 1.1;
gzip_disable "MSIE [1-6]\.";
gzip_min_length 256;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_comp_level 9;
client_max_body_size 64M;
root /usr/share/nginx/html;
location /api {
proxy_pass http://pcaprofiler_api:6867/api;
}
location /static/ {
alias /static/;
add_header Content-disposition "attachment";
}
location / {
try_files $uri @index;
}
location @index {
add_header Cache-Control no-cache;
expires 0;
try_files /index.html =404;
}
}
And this is my ini-letsencrypt.sh that i use to launch all:
#!/bin/bash
source .env
domains=(${WEB_DOMAIN} www.${WEB_DOMAIN})
rsa_key_size=4096
data_path="./data/certbot"
email="theurillat.team@gmail.com" # Adding a valid address is strongly recommended
staging=${CERT_STAGING} # Set to 1 if you're testing your setup to avoid hitting request limits
if [ -d "$data_path" ]; then
read -p "Existing data found for $domains. Continue and replace existing certificate? (y/N) " decision
if [ "$decision" != "Y" ] && [ "$decision" != "y" ]; then
exit
fi
fi
if [ ! -e "$data_path/conf/options-ssl-nginx.conf" ] || [ ! -e "$data_path/conf/ssl-dhparams.pem" ]; then
echo "### Downloading recommended TLS parameters ..."
mkdir -p "$data_path/conf"
curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot-nginx/certbot_nginx/_internal/tls_configs/options-ssl-nginx.conf > "$data_path/conf/options-ssl-nginx.conf"
curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot/certbot/ssl-dhparams.pem > "$data_path/conf/ssl-dhparams.pem"
echo
fi
echo "### Creating dummy certificate for $domains ..."
path="/etc/letsencrypt/live/$domains"
mkdir -p "$data_path/conf/live/$domains"
docker compose run --rm --entrypoint "\
openssl req -x509 -nodes -newkey rsa:$rsa_key_size -days 1\
-keyout '$path/privkey.pem' \
-out '$path/fullchain.pem' \
-subj '/CN=localhost'" certbot
echo
echo "### Starting nginx ..."
docker compose up --force-recreate -d pcaprofiler_ui
echo
echo "### Deleting dummy certificate for $domains ..."
docker compose run --rm --entrypoint "\
rm -Rf /etc/letsencrypt/live/$domains && \
rm -Rf /etc/letsencrypt/archive/$domains && \
rm -Rf /etc/letsencrypt/renewal/$domains.conf" certbot
echo
echo "### Requesting Let's Encrypt certificate for $domains ..."
#Join $domains to -d args
domain_args=""
for domain in "${domains[@]}"; do
domain_args="$domain_args -d $domain"
done
# Select appropriate email arg
case "$email" in
"") email_arg="--register-unsafely-without-email" ;;
*) email_arg="--email $email" ;;
esac
# Enable staging mode if needed
if [ $staging != "0" ]; then staging_arg="--staging"; fi
docker compose run --rm --entrypoint "\
certbot certonly --webroot -w /var/www/certbot \
$staging_arg \
$email_arg \
$domain_args \
--rsa-key-size $rsa_key_size \
--agree-tos \
--force-renewal" certbot
echo
echo "### Reloading nginx ..."
docker compose exec pcaprofiler_ui nginx -s reload
My web server is: nginx/1.20.2
The operating system my web server runs on is:
Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename: jammy
My hosting provider, if applicable, is: hetzner
I can login to a root shell on my machine.
Thanks all fro help!