#!/bin/sh set -eu CONF=/etc/nginx/conf.d/default.conf # 集群内真实 Service:project57-svc:80(不是 project57-deploy:3000) A_UPSTREAM="${A_UPSTREAM:-http://project57-svc.ns-project57.svc.cluster.local:80}" A_UPSTREAM="${A_UPSTREAM%/}" 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 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_PUBLIC__|${A_PUBLIC}|g" \ "${CONF}" echo "nginx upstream: ${A_UPSTREAM} (resolver ${NS}, public ${A_PUBLIC})" nginx -t