mirror of
https://github.com/nginx-proxy/docker-letsencrypt-nginx-proxy-companion
synced 2024-11-15 13:43:11 +01:00
Merge pull request #683 from buchdag/fix-674
Don't incorrectly grep existing subdomain with add_standalone_configuration()
This commit is contained in:
commit
88949415bd
@ -104,7 +104,7 @@ function add_location_configuration {
|
||||
|
||||
function add_standalone_configuration {
|
||||
local domain="${1:?}"
|
||||
if grep -q "$domain" "/etc/nginx/conf.d/default.conf"; then
|
||||
if grep -q "server_name ${domain};" "/etc/nginx/conf.d/default.conf"; then
|
||||
# If the domain is already present in nginx's conf, use the location configuration.
|
||||
add_location_configuration "$domain"
|
||||
else
|
||||
|
@ -1,3 +1,4 @@
|
||||
Started test web server for sub.le1.wtf
|
||||
Started letsencrypt container for test certs_standalone
|
||||
Symlink to le1.wtf certificate has been generated.
|
||||
The link is pointing to the file ./le1.wtf/fullchain.pem
|
||||
|
@ -10,9 +10,12 @@ fi
|
||||
|
||||
# Create the $domains array from comma separated domains in TEST_DOMAINS.
|
||||
IFS=',' read -r -a domains <<< "$TEST_DOMAINS"
|
||||
subdomain="sub.${domains[0]}"
|
||||
|
||||
# Cleanup function with EXIT trap
|
||||
function cleanup {
|
||||
# Remove the Nginx container silently.
|
||||
docker rm --force "$subdomain" > /dev/null 2>&1
|
||||
# Cleanup the files created by this run of the test to avoid foiling following test(s).
|
||||
docker exec "$le_container_name" bash -c 'rm -rf /etc/nginx/certs/le?.wtf*'
|
||||
# Stop the LE container
|
||||
@ -26,9 +29,20 @@ LETSENCRYPT_STANDALONE_CERTS=('single')
|
||||
LETSENCRYPT_single_HOST=('${domains[0]}')
|
||||
EOF
|
||||
|
||||
# Run an nginx container with a VIRTUAL_HOST set to a subdomain of ${domains[0]} in order to check for
|
||||
# this regression : https://github.com/nginx-proxy/docker-letsencrypt-nginx-proxy-companion/issues/674
|
||||
docker run --rm -d \
|
||||
--name "$subdomain" \
|
||||
-e "VIRTUAL_HOST=$subdomain" \
|
||||
--network boulder_bluenet \
|
||||
nginx:alpine > /dev/null && echo "Started test web server for $subdomain"
|
||||
|
||||
run_le_container ${1:?} "$le_container_name" \
|
||||
"--volume ${TRAVIS_BUILD_DIR}/test/tests/certs_standalone/letsencrypt_user_data:/app/letsencrypt_user_data"
|
||||
|
||||
# Wait for a file at /etc/nginx/conf.d/standalone-cert-${domains[0]}.conf
|
||||
wait_for_standalone_conf "${domains[0]}" "$le_container_name"
|
||||
|
||||
# Wait for a symlink at /etc/nginx/certs/${domains[0]}.crt
|
||||
# then grab the certificate in text form ...
|
||||
wait_for_symlink "${domains[0]}" "$le_container_name"
|
||||
@ -55,6 +69,11 @@ EOF
|
||||
# Manually trigger the service loop
|
||||
docker exec "$le_container_name" /app/signal_le_service > /dev/null
|
||||
|
||||
for domain in "${domains[1]}" "${domains[2]}"; do
|
||||
# Wait for a file at /etc/nginx/conf.d/standalone-cert-$domain.conf
|
||||
wait_for_standalone_conf "$domain" "$le_container_name"
|
||||
done
|
||||
|
||||
# Wait for a symlink at /etc/nginx/certs/${domains[1]}.crt
|
||||
# then grab the certificate in text form ...
|
||||
wait_for_symlink "${domains[1]}" "$le_container_name"
|
||||
|
@ -32,6 +32,24 @@ function run_le_container {
|
||||
export -f run_le_container
|
||||
|
||||
|
||||
# Wait for the /etc/nginx/conf.d/standalone-cert-$1.conf file to exist inside container $2
|
||||
function wait_for_standalone_conf {
|
||||
local domain="${1:?}"
|
||||
local name="${2:?}"
|
||||
local i=0
|
||||
local target
|
||||
until docker exec "$name" [ -f "/etc/nginx/conf.d/standalone-cert-$domain.conf" ]; do
|
||||
if [ $i -gt 600 ]; then
|
||||
echo "Standalone configuration file for $domain was not generated under one minute, timing out."
|
||||
return 1
|
||||
fi
|
||||
i=$((i + 10))
|
||||
sleep 0.1
|
||||
done
|
||||
}
|
||||
export -f wait_for_standalone_conf
|
||||
|
||||
|
||||
# Wait for the /etc/nginx/certs/$1.crt symlink to exist inside container $2
|
||||
function wait_for_symlink {
|
||||
local domain="${1:?}"
|
||||
|
Loading…
Reference in New Issue
Block a user