-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·83 lines (71 loc) · 2.71 KB
/
entrypoint.sh
File metadata and controls
executable file
·83 lines (71 loc) · 2.71 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env sh
set -euo pipefail
TEMPLATE_PATH="/etc/nginx/templates/nginx.conf.template"
OUTPUT_PATH="/etc/nginx/nginx.conf"
: "${DOMAIN:=localhost}"
: "${RANCHER_UPSTREAM:=}"
export DOMAIN RANCHER_UPSTREAM
if [ ! -f "${TEMPLATE_PATH}" ]; then
echo "nginx template not found at ${TEMPLATE_PATH}" >&2
exit 1
fi
RANCHER_LOCATIONS=""
if [ -n "${RANCHER_UPSTREAM}" ]; then
RANCHER_LOCATIONS="$(cat <<'EOF'
# Rancher dashboard and APIs
location /dashboard {
proxy_pass ${RANCHER_UPSTREAM};
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}
location /v3 {
proxy_pass ${RANCHER_UPSTREAM};
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}
location /v1 {
proxy_pass ${RANCHER_UPSTREAM};
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}
location /k8s {
proxy_pass ${RANCHER_UPSTREAM};
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}
EOF
)"
RANCHER_LOCATIONS="$(printf '%s' "${RANCHER_LOCATIONS}" | envsubst '${RANCHER_UPSTREAM}')"
fi
export RANCHER_LOCATIONS
envsubst '${DOMAIN} ${RANCHER_LOCATIONS}' < "${TEMPLATE_PATH}" > "${OUTPUT_PATH}"
nginx -t
exec nginx -g 'daemon off;'