-
Notifications
You must be signed in to change notification settings - Fork 5
/
entrypoint.sh
executable file
·55 lines (42 loc) · 1.33 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
cat <<EOF
Welcome to the nginx-mod_security container
IMPORTANT:
IF you use SSL inside your personal NGINX-config,
you should add the Strict-Transport-Security header like:
# only this domain
add_header Strict-Transport-Security "max-age=31536000";
# apply also on subdomains
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
to your config.
After this you should gain a A+ Grade on the Qualys SSL Test
EOF
if [ -z ${DH_SIZE+x} ]
then
>&2 echo ">> no \$DH_SIZE specified using default"
DH_SIZE="2048"
fi
DH="/etc/nginx/external/dh.pem"
if [ ! -e "$DH" ]
then
echo ">> seems like the first start of nginx"
echo ">> doing some preparations..."
echo ""
echo ">> generating $DH with size: $DH_SIZE"
openssl dhparam -out "$DH" $DH_SIZE
fi
if [ ! -e "/etc/nginx/external/cert.pem" ] || [ ! -e "/etc/nginx/external/key.pem" ]
then
echo ">> generating self signed cert"
openssl req -x509 -newkey rsa:4086 \
-subj "/C=XX/ST=XXXX/L=XXXX/O=XXXX/CN=localhost" \
-keyout "/etc/nginx/external/key.pem" \
-out "/etc/nginx/external/cert.pem" \
-days 3650 -nodes -sha256
fi
echo ">> copy /etc/nginx/external/*.conf files to /etc/nginx/conf.d/"
cp /etc/nginx/external/*.conf /etc/nginx/conf.d/ 2> /dev/null > /dev/null
# exec CMD
echo ">> exec docker CMD"
echo "$@"
exec "$@"