- Dockerfile: nginx:1.27-alpine serving the exported site, PORT from env, /healthz healthcheck, origin rewrite hook in docker-entrypoint.d - docker/default.conf.template: envsubst PORT, clean URLs without trailing-slash redirect, long cache for hashed assets, no-cache for HTML/sw.js/manifest, 301 http->https via X-Forwarded-Proto, gzip - docker/security-headers.conf: single include so add_header survives per location - docker-compose.yml (Dokploy, no host ports) + docker-compose.override.yml (local) - bake canonical/OG/sitemap/robots origin to https://alterflixhub.hobbypj.com (was the export-time 127.0.0.1:8090), overridable via PUBLIC_ORIGIN - docs/deploy-dokploy.md
25 lines
1.1 KiB
Bash
25 lines
1.1 KiB
Bash
#!/bin/sh
|
|
# แทน origin ที่อบไว้ในไฟล์ static (canonical / og:url / JSON-LD / sitemap / robots / ai.txt)
|
|
# ใช้เมื่อ PUBLIC_ORIGIN ต่างจาก BAKED_ORIGIN เช่น deploy ขึ้นโดเมนใหม่หรือ preview หลายโดเมน
|
|
# ไม่ตั้งค่า = ใช้ origin ที่อบมาแล้ว (ไม่มีอะไรเปลี่ยน)
|
|
set -eu
|
|
|
|
PUBLIC_ORIGIN="${PUBLIC_ORIGIN:-}"
|
|
BAKED_ORIGIN="${BAKED_ORIGIN:-}"
|
|
|
|
if [ -z "$PUBLIC_ORIGIN" ] || [ "$PUBLIC_ORIGIN" = "$BAKED_ORIGIN" ]; then
|
|
echo "origin: ใช้ค่าที่อบมา ($BAKED_ORIGIN) — ไม่ต้องแทนที่"
|
|
exit 0
|
|
fi
|
|
|
|
DOC_ROOT=/usr/share/nginx/html
|
|
changed=0
|
|
for f in $(find "$DOC_ROOT" -type f \( -name '*.html' -o -name '*.xml' -o -name '*.txt' \)); do
|
|
if grep -qF "$BAKED_ORIGIN" "$f"; then
|
|
sed -i "s|${BAKED_ORIGIN}|${PUBLIC_ORIGIN}|g" "$f"
|
|
changed=$((changed + 1))
|
|
fi
|
|
done
|
|
|
|
echo "origin: แทนที่ ${BAKED_ORIGIN} → ${PUBLIC_ORIGIN} ใน ${changed} ไฟล์"
|