Some bugfixes.

This commit is contained in:
2021-07-01 18:49:49 +00:00
parent 4faddd10b8
commit 58ec63c882
4 changed files with 29 additions and 21 deletions

View File

@@ -24,20 +24,19 @@ openssl req -x509 -newkey rsa:4096 -keyout $CERT_DIR/key.pem -out $CERT_DIR/full
}
if [[ "$(ls -A $CERT_DIR)" == "" ]]; then
if [[ "$(ls $CERT_DIR)" == "" ]]; then
echo "$DOMAIN not contains certificates, creates new."
mkdir -p $CERT_DIR;
CURL_CHECK="curl -s -o /dev/null -w "%{http_code}" https://$LETSENCRYPT_URL";
if [[ "$(eval $CURL_CHECK)" != "200" ]] ; then
create_self_signed_certificate;
fi
else
file="$CERT_DIR/letsencrypt"
{
echo "{ \"DOMAIN\": \"$DOMAIN\" }"
} >> "$file"
fi
CURL_CHECK="curl -s -o /dev/null -w "%{http_code}" https://$LETSENCRYPT_URL";
if [[ "$(eval $CURL_CHECK)" != "200" ]] ; then
create_self_signed_certificate;
else
letsencrypt_certificates;
fi

View File

@@ -0,0 +1,12 @@
#!/bin/sh
ref="${1:-library/ubuntu:latest}"
repo="${ref%:*}"
tag="${ref##*:}"
acceptM="application/vnd.docker.distribution.manifest.v2+json"
acceptML="application/vnd.docker.distribution.manifest.list.v2+json"
token=$(curl -s "https://auth.docker.io/token?service=registry.docker.io&scope=repository:${repo}:pull" | jq -r '.token')
curl -H "Accept: ${acceptM}" \
-H "Accept: ${acceptML}" \
-H "Authorization: Bearer $token" \
-I -s "https://registry-1.docker.io/v2/${repo}/manifests/${tag}"

View File

@@ -7,6 +7,7 @@ DEL=$2
if [[ $DEL != "" ]]; then
echo "$DOMAIN DELETED";
rm $DOMAIN.conf;
exit 0;
fi
DOMAIN_SOURCE=/domains/$DOMAIN
@@ -31,7 +32,7 @@ echo $DOMAIN;
file="/tmp/$DOMAIN.conf"
cp -a /scripts/nginx_template.conf /tmp/$DOMAIN.conf
#cp -a /scripts/nginx_template.conf /tmp/$DOMAIN.conf
{
@@ -44,11 +45,11 @@ rewrite_log on;"
echo
if [[ $REDIRECT_HTTP != "" && $HTTP_PORT != "" ]]; then
echo "return 301 http://$REDIRECT_HTTP;
}"
echo "return 301 http://$REDIRECT_HTTP;"
elif [[ $REDIRECT_HTTPS != "" && $HTTP_PORT != "" ]]; then
echo "return 301 https://$REDIRECT_HTTPS;
}"
echo "return 301 https://$REDIRECT_HTTPS;"
else
if [[ $ERROR_PAGE != "" && $HTTP_PORT != "" ]]; then
echo "error_page 404 /$ERROR_PAGE;
@@ -75,11 +76,7 @@ location = /$ERROR_PAGE {
proxy_set_header Connection "'$http_connection'";
proxy_cookie_path / /;
access_log off;
}"
fi
if [[ $HTTPS_PORT == "" ]] ; then
echo "}
}
}"
fi
@@ -128,7 +125,6 @@ echo "proxy_redirect off;
proxy_set_header Connection "'$http_connection'";
proxy_cookie_path / /;
access_log off;
}
}
}"
fi

View File

@@ -178,8 +178,9 @@ do
parent="/"$(echo $dir|cut -d / -f2)
if [[ "${parent}" == "${CERT_DIR}" && "${op}" == "CREATE,CLOSE_WRITE,CLOSE" && "${file}" == "new_certificate" ]]; then
if [[ "${parent}" == "${CERT_DIR}" && "${op}" == "CREATE,CLOSE_WRITE,CLOSE" ]]; then
DOMAIN=$(echo $dir|cut -d / -f3);
echo "file: "$file;
echo "New cert created: '$DOMAIN'";
#check_proxy_state;