-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10-setup.sh
More file actions
55 lines (43 loc) · 1.38 KB
/
10-setup.sh
File metadata and controls
55 lines (43 loc) · 1.38 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
48
49
50
51
52
53
54
55
#!/usr/bin/env sh
set -e
echo "Running: ${0}"
_NGINX_INDEX="index.html index.htm"
_STATIC="/static"
echo "STATIC: ${STATIC:-$_STATIC}"
echo "SUID: ${SUID:-1000}"
echo "NGINX_INDEX: ${NGINX_INDEX:=$_NGINX_INDEX}"
sed "s/NGINX_INDEX/${NGINX_INDEX:=$_NGINX_INDEX}/g" \
-i /etc/nginx/nginx.conf
rm -f /etc/nginx/conf.d/http.gzip.conf
rm -f /etc/nginx/conf.d/location.auth.conf
rm -f /etc/nginx/auth.users
: "${GZIP_TYPES:=*}"
echo "GZIP_TYPES: ${GZIP_TYPES}"
if [ "${GZIP_TYPES}" != "off" ];then
cat <<EOF >> /etc/nginx/conf.d/http.gzip.conf
gzip on;
gzip_proxied any;
gzip_min_length ${GZIP_LENGTH:-1000};
gzip_types ${GZIP_TYPES};
EOF
fi
: "${ERROR_PAGE:=/404.html}"
if [ "${ERROR_PAGE}" != "off" ];then
echo "ERROR_PAGE: ${ERROR_PAGE}"
echo "error_page 404 ${ERROR_PAGE};" >> /etc/nginx/conf.d/location.auth.conf
sed "s,ERROR_PAGE,${ERROR_PAGE},g" -i /etc/nginx/nginx.conf
else
sed "s/ERROR_PAGE//g" -i /etc/nginx/nginx.conf
fi
if [ -n "${BASIC_AUTH}" ];then
echo "BASIC_AUTH: ${BASIC_AUTH}"
printf '%s' "${BASIC_AUTH}" > /etc/nginx/auth.users
cat <<EOF >> /etc/nginx/conf.d/location.auth.conf
auth_basic "${BASIC_REALM:-Unauthorized}";
auth_basic_user_file /etc/nginx/auth.users;
EOF
fi
echo "+ chown -R ${SUID:-1000}:${SUID:-1000} ${STATIC:-$_STATIC}"
chown -R "${SUID:-1000}:${SUID:-1000}" "${STATIC:-$_STATIC}"
echo "${0} - Done"
nginx -version ||: