/.well-known/acme-challenge does not exist or is not a directory
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /tmp/tmpivsrd3cl/log or re-run Certbot with -v for more details.
Reloading nginx ...
2021/12/16 10:05:52 [notice] 12#12: signal process started
My web server is (include version): I use Nginx
The operating system my web server runs on is (include version): ubuntu 16.04
#!/bin/bash
if ! [ -x "$(command -v docker-compose)" ]; then
echo 'Error: docker-compose is not installed.' >&2
exit 1
fi
domains=(portal.comp-moto.com www.portal.comp-moto.com)
rsa_key_size=4096
data_path="./data/certbot"
email="khamonluck.ang@gmail.com" # Adding a valid address is strongly recommended
staging=0 # 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 nginx
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 \
--dry-run"
echo
echo "### Reloading nginx ..."
docker-compose exec nginx nginx -s reload
and I got error here
### Creating dummy certificate for portal.comp-moto.com ...
Generating a RSA private key
..................................................................................................................................................................................................++++
............................................................................................................................++++
writing new private key to '/etc/letsencrypt/live/portal.comp-moto.com/privkey.pem'
-----
### Starting nginx ...
Recreating comp_moto_redis ... done
Recreating comp_moto_app ... done
Recreating comp_moto_web ... done
### Deleting dummy certificate for portal.comp-moto.com ...
### Requesting Let's Encrypt certificate for portal.comp-moto.com ...
Run a one-off command on a service.
For example:
$ docker-compose run web python manage.py shell
By default, linked services will be started, unless they are already
running. If you do not want to start linked services, use
`docker-compose run --no-deps SERVICE COMMAND [ARGS...]`.
Usage:
run [options] [-v VOLUME...] [-p PORT...] [-e KEY=VAL...] [-l KEY=VALUE...]
SERVICE [COMMAND] [ARGS...]
Options:
-d, --detach Detached mode: Run container in the background, print
new container name.
--name NAME Assign a name to the container
--entrypoint CMD Override the entrypoint of the image.
-e KEY=VAL Set an environment variable (can be used multiple times)
-l, --label KEY=VAL Add or override a label (can be used multiple times)
-u, --user="" Run as specified username or uid
--no-deps Don't start linked services.
--rm Remove container after run. Ignored in detached mode.
-p, --publish=[] Publish a container's port(s) to the host
--service-ports Run command with the service's ports enabled and mapped
to the host.
--use-aliases Use the service's network aliases in the network(s) the
container connects to.
-v, --volume=[] Bind mount a volume (default [])
-T Disable pseudo-tty allocation. By default `docker-compose run`
allocates a TTY.
-w, --workdir="" Working directory inside the container
### Reloading nginx ...
Error response from daemon: Container 497a3f8898d68eb3c2f8df15a2acf6f6e73d2ae9e40b43d0b44f988b1f81151f is restarting, wait until the container is running
and my Nginx container log show this error
2021/12/17 04:36:09 [crit] 1#1: pread() "/etc/letsencrypt/options-ssl-nginx.conf" failed (21: Is a directory)
nginx: [crit] pread() "/etc/letsencrypt/options-ssl-nginx.conf" failed (21: Is a directory)
I can not build docker because it will can not file letsencrypt file and I can not run my script, it wait until the container is running. what should I do?
### Creating dummy certificate for portal.comp-moto.com ...
Generating a RSA private key
.....................................................................................+++++
............+++++
writing new private key to '/etc/letsencrypt/live/portal.comp-moto.com/privkey.pem'
-----
### Starting nginx ...
Recreating comp_moto_redis ... done
Recreating comp_moto_app ... done
Recreating comp_moto_web ... done
### Deleting dummy certificate for portal.comp-moto.com ...
### Requesting Let's Encrypt certificate for portal.comp-moto.com ...
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Simulating a certificate request for portal.comp-moto.com
Certbot failed to authenticate some domains (authenticator: webroot). The Certificate Authority reported these problems:
Domain: portal.comp-moto.com
Type: unauthorized
Detail: Invalid response from https://portal.comp-moto.com/.well-known/acme-challenge/o2oEWSywu0_dYpTEunVSIU3QnSmIEvfvX8y-KQQ--gg [103.86.51.196]: "<html>\r\n<head><title>404 Not Found</title></head>\r\n<body>\r\n<center><h1>404 Not Found</h1></center>\r\n<hr><center>nginx</center>\r\n"
Hint: The Certificate Authority failed to download the temporary challenge files created by Certbot. Ensure that the listed domains serve their content from the provided --webroot-path/-w and that files created there can be downloaded from the internet.
Some challenges have failed.
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.
### Reloading nginx ...
2021/12/17 05:23:04 [emerg] 12#12: cannot load certificate "/etc/letsencrypt/live/portal.comp-moto.com/fullchain.pem": BIO_new_file() failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/letsencrypt/live/portal.comp-moto.com/fullchain.pem','r') error:2006D080:BIO routines:BIO_new_file:no such file)
nginx: [emerg] cannot load certificate "/etc/letsencrypt/live/portal.comp-moto.com/fullchain.pem": BIO_new_file() failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/letsencrypt/live/portal.comp-moto.com/fullchain.pem','r') error:2006D080:BIO routines:BIO_new_file:no such file)
and this is my script
#!/bin/bash
if ! [ -x "$(command -v docker-compose)" ]; then
echo 'Error: docker-compose is not installed.' >&2
exit 1
fi
domains=(portal.comp-moto.com)
rsa_key_size=4096
data_path="./data/certbot"
email="khamonluck.ang@gmail.com" # Adding a valid address is strongly recommended
staging=0 # 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:1024 -days 1\
-keyout '$path/privkey.pem' \
-out '$path/fullchain.pem' \
-subj '/CN=localhost'" certbot
echo
echo "### Starting nginx ..."
docker-compose up --force-recreate -d nginx
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 \
--dry-run" certbot
echo
echo "### Reloading nginx ..."
docker-compose exec nginx nginx -s reload
I still got this, I'm so confused, I pointed webroot already on Nginx.conf and on docker-compose(Certbot image)
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Simulating a certificate request for portal.comp-moto.com
Certbot failed to authenticate some domains (authenticator: webroot). The Certificate Authority reported these problems:
Domain: portal.comp-moto.com
Type: unauthorized
Detail: Invalid response from https://portal.comp-moto.com/.well-known/acme-challenge/7uNbYHVfKwGS0b2g7gf4FFCj51W5vFNs3FLDgEeaGNY [103.86.51.196]: "<html>\r\n<head><title>404 Not Found</title></head>\r\n<body>\r\n<center><h1>404 Not Found</h1></center>\r\n<hr><center>nginx</center>\r\n"
Hint: The Certificate Authority failed to download the temporary challenge files created by Certbot. Ensure that the listed domains serve their content from the provided --webroot-path/-w and that files created there can be downloaded from the internet.
Some challenges have failed.
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.
I run certbot command inside certbot container and then I got this
/opt/certbot # certbot certonly --webroot -w /var/www/certbot
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Please enter the domain name(s) you would like on your certificate (comma and/or
space separated) (Enter 'c' to cancel): portal.comp-moto.com
Requesting a certificate for portal.comp-moto.com
Certbot failed to authenticate some domains (authenticator: webroot). The Certificate Authority reported these problems:
Domain: portal.comp-moto.com
Type: unauthorized
Detail: Invalid response from https://portal.comp-moto.com/.well-known/acme-challenge/Gg4p39t4hYEVTTby41i166mNjwGq-1jh-KqGsyffIUg [103.86.51.196]: "<html>\r\n<head><title>404 Not Found</title></head>\r\n<body>\r\n<center><h1>404 Not Found</h1></center>\r\n<hr><center>nginx</center>\r\n"
Hint: The Certificate Authority failed to download the temporary challenge files created by Certbot. Ensure that the listed domains serve their content from the provided --webroot-path/-w and that files created there can be downloaded from the internet.
Some challenges have failed.
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.
I did run certbot certonly --webroot -w /var/www/certbot inside Certbot container again, it was success
root@portal:~/comp_moto# docker exec -it comp_moto_certbot_1 /bin/sh
/opt/certbot # certbot certonly --webroot -w /var/www/certbot
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Please enter the domain name(s) you would like on your certificate (comma and/or
space separated) (Enter 'c' to cancel): portal.comp-moto.com
Requesting a certificate for portal.comp-moto.com
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/portal.comp-moto.com/fullchain.pem
Key is saved at: /etc/letsencrypt/live/portal.comp-moto.com/privkey.pem
This certificate expires on 2022-03-17.
These files will be updated when the certificate renews.
NEXT STEPS:
- The certificate will need to be renewed before it expires. Certbot can automatically renew the certificate in the background, but you may need to take steps to enable that functionality. See https://certbot.org/renewal-setup for instructions.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
* Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
* Donating to EFF: https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
but when i run my script, it still the same error like this
root@portal:~/comp_moto# sudo ./init-letsencrypt.sh
Existing data found for portal.comp-moto.com. Continue and replace existing certificate? (y/N) y
### Creating dummy certificate for portal.comp-moto.com ...
Generating a RSA private key
.................+++++
.................................+++++
writing new private key to '/etc/letsencrypt/live/portal.comp-moto.com/privkey.pem'
-----
### Starting nginx ...
Recreating comp_moto_redis ... done
Recreating comp_moto_app ... done
Recreating comp_moto_web ... done
### Deleting dummy certificate for portal.comp-moto.com ...
### Requesting Let's Encrypt certificate for portal.comp-moto.com ...
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Simulating a certificate request for portal.comp-moto.com
Certbot failed to authenticate some domains (authenticator: webroot). The Certificate Authority reported these problems:
Domain: portal.comp-moto.com
Type: unauthorized
Detail: During secondary validation: Invalid response from https://portal.comp-moto.com/.well-known/acme-challenge/N-TJnnIUhgo9qsU746hxk4K6XdPMedjNJj8uK78b8yQ [103.154.94.148]: "<!DOCTYPE html>\n<html>\n<head>\n <title>The page you were looking for doesn't exist (404)</title>\n <meta name=\"viewport\" content"
Hint: The Certificate Authority failed to download the temporary challenge files created by Certbot. Ensure that the listed domains serve their content from the provided --webroot-path/-w and that files created there can be downloaded from the internet.
Some challenges have failed.
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.
### Reloading nginx ...
2021/12/17 10:03:03 [emerg] 12#12: cannot load certificate "/etc/letsencrypt/live/portal.comp-moto.com/fullchain.pem": BIO_new_file() failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/letsencrypt/live/portal.comp-moto.com/fullchain.pem','r') error:2006D080:BIO routines:BIO_new_file:no such file)
nginx: [emerg] cannot load certificate "/etc/letsencrypt/live/portal.comp-moto.com/fullchain.pem": BIO_new_file() failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/letsencrypt/live/portal.comp-moto.com/fullchain.pem','r') error:2006D080:BIO routines:BIO_new_file:no such file)