27 lines
751 B
Bash
27 lines
751 B
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
CONF=/etc/nginx/conf.d/default.conf
|
|
# 集群内 ClusterIP:80 会 Connection refused,改走已验证可通的 A 站公网
|
|
A_UPSTREAM="${A_UPSTREAM:-https://project57.website-build.org}"
|
|
A_UPSTREAM="${A_UPSTREAM%/}"
|
|
|
|
A_HOST="$(printf '%s' "${A_UPSTREAM}" | sed -E 's|^[a-zA-Z][a-zA-Z0-9+.-]*://||; s|[:/].*$||')"
|
|
if [ -z "${A_HOST}" ]; then
|
|
A_HOST=project57.website-build.org
|
|
fi
|
|
|
|
NS="$(awk '/^nameserver/{print $2; exit}' /etc/resolv.conf || true)"
|
|
if [ -z "${NS}" ]; then
|
|
NS=kube-dns.kube-system.svc.cluster.local
|
|
fi
|
|
|
|
sed -i \
|
|
-e "s|__RESOLVER__|${NS}|g" \
|
|
-e "s|__A_UPSTREAM__|${A_UPSTREAM}|g" \
|
|
-e "s|__A_HOST__|${A_HOST}|g" \
|
|
"${CONF}"
|
|
|
|
echo "nginx upstream: ${A_UPSTREAM} (Host ${A_HOST}, resolver ${NS})"
|
|
nginx -t
|