forked from recmo/docker-lets-encrypt-proxy
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinit.sh
More file actions
executable file
·47 lines (42 loc) · 1.46 KB
/
Copy pathinit.sh
File metadata and controls
executable file
·47 lines (42 loc) · 1.46 KB
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
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh
set +e
echo "Machine has $(grep processor /proc/cpuinfo | wc -l) cores and $(awk '/MemTotal/ {print $2}' /proc/meminfo) kB RAM."
# Create cache folders if they don't exits
mkdir -p /cache/ssl /cache/web
chown nobody:nobody -R /cache/ssl /cache/web
# This step is very slow, you can cache it by keeping
# a rw volume mounted on /cache. Re-using the dhparam.pem
# does not hurt security much.
if [ ! -f /cache/ssl/dhparam.pem ]
then
echo "Generating Diffie-Hellman parameters...(2048 bit)"
echo "This takes about 20 minutes. You can cache it by mounting a"
echo "rw volume under \"/cache\"."
openssl dhparam -out /cache/ssl/dhparam.pem 2048
else
echo "Using existing Diffie-Hellman parameters."
fi
if [ ! -f /cache/ssl/resty-auto-ssl-fallback.key ]
then
echo "Generating self-signed fallback certificate..."
openssl req -new -newkey rsa:4096 -days 3650 -nodes -x509 \
-subj '/CN=sni-support-required-for-valid-ssl' \
-keyout /cache/ssl/resty-auto-ssl-fallback.key \
-out /cache/ssl/resty-auto-ssl-fallback.crt
else
echo "Using existing self-signed fallback certificate."
fi
echo "Configuring nginx..."
if [ -z "$ORIGIN_HOST" ]; then
echo "You need to provide the upstream hostname in \$ORIGIN_HOST"
exit 1
fi
VARIABLES=" \$ORIGIN_HOST"
for FILE in /etc/nginx/*.conf
do
echo "$FILE"
envsubst "$VARIABLES" < "$FILE" > "$FILE.tmp"
mv "$FILE.tmp" "$FILE"
done
echo "Starting nginx..."
exec /usr/local/openresty/bin/openresty -c /etc/nginx/nginx.conf -g "daemon off;"