feat: proxy admin and Next assets via cluster service [deploy]
This commit is contained in:
1 parent
8a28342a81
commit
1ffb91509c
4 files changed
+67
-34
No files matched your search
@@ -2,15 +2,11 @@
|
||||
set -eu
|
||||
|
||||
CONF=/etc/nginx/conf.d/default.conf
|
||||
# A 站已有公网域名时走公网更稳;也可设为集群内 http://service.ns.svc:port
|
||||
A_UPSTREAM="${A_UPSTREAM:-https://project57.website-build.org}"
|
||||
# 集群内真实 Service:project57-svc:80(不是 project57-deploy:3000)
|
||||
A_UPSTREAM="${A_UPSTREAM:-http://project57-svc.ns-project57.svc.cluster.local:80}"
|
||||
A_UPSTREAM="${A_UPSTREAM%/}"
|
||||
|
||||
# 从 URL 提取 Host,供反代 Host / SNI(Cloudflare/Ingress 依赖正确 Host)
|
||||
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
|
||||
A_PUBLIC="${A_PUBLIC:-https://project57.website-build.org}"
|
||||
A_PUBLIC="${A_PUBLIC%/}"
|
||||
|
||||
NS="$(awk '/^nameserver/{print $2; exit}' /etc/resolv.conf || true)"
|
||||
if [ -z "${NS}" ]; then
|
||||
@@ -20,8 +16,8 @@ fi
|
||||
sed -i \
|
||||
-e "s|__RESOLVER__|${NS}|g" \
|
||||
-e "s|__A_UPSTREAM__|${A_UPSTREAM}|g" \
|
||||
-e "s|__A_HOST__|${A_HOST}|g" \
|
||||
-e "s|__A_PUBLIC__|${A_PUBLIC}|g" \
|
||||
"${CONF}"
|
||||
|
||||
echo "nginx upstream: ${A_UPSTREAM} (Host ${A_HOST}, resolver ${NS})"
|
||||
echo "nginx upstream: ${A_UPSTREAM} (resolver ${NS}, public ${A_PUBLIC})"
|
||||
nginx -t
|
||||
Reference in new issue
Block a user