-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathentrypoint.sh
executable file
·36 lines (29 loc) · 1.09 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
set -e
# Prepare nginx configuration
HTTP_DOMAINS=$(echo "$NGINX_PROXY_PASS" | gen.py http)
HTTPS_DOMAINS=$(echo "$NGINX_PROXY_PASS" | gen.py https)
CERTBOT_DOMAINS=$(echo "$NGINX_PROXY_PASS" | gen.py certbot)
NGINX_UPSTREAMS=$(echo "$NGINX_PROXY_PASS" | gen.py upstreams)
export HTTP_DOMAINS="${HTTP_DOMAINS:-localhost}" # use localhost if no http hosts defined
export HTTPS_DOMAINS
envsubst '$HTTP_DOMAINS $HTTPS_DOMAINS' < http.conf.tpl > http.conf
echo "$NGINX_UPSTREAMS" > upstreams.conf
# Write custom nginx config
if [[ ! -z "$NGINX_CUSTOM_CONFIG" ]]; then
echo "$NGINX_CUSTOM_CONFIG" > custom.conf
fi
# Request certificates at first start (if there are any https hosts)
if [ ! -z "$HTTPS_DOMAINS" ] && [ ! -e /etc/letsencrypt/live ]; then
certbot certonly --standalone --non-interactive $CERTBOT_ARGS \
--cert-name cert \
--agree-tos --email $CERTBOT_EMAIL \
$CERTBOT_DOMAINS
fi
# Generate dhparams if not existing yet
if [ ! -e /var/lib/letsencrypt/dhparam.pem ]; then
openssl dhparam -out /var/lib/letsencrypt/dhparam.pem 2048
fi
# Start
crond
nginx -g "daemon off;"