Add backend-generated sitemap with website manifest sync and nginx SEO proxy support.
Stores synced route config from /meshkee/sitemap-config.json, serves sitemap.xml and robots.txt per tenant, and invalidates cache on CMS writes. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
c7d5204b49
commit
2e8d7c1cfd
@@ -9,6 +9,9 @@
|
||||
# POST /ssl { host, slug? } — certbot for apex + www (nginx must exist)
|
||||
# GET /health
|
||||
#
|
||||
# Scripts on the VM (same folder):
|
||||
# patch-nginx-seo.sh <host> — add /sitemap.xml + /robots.txt API proxies to an existing nginx site
|
||||
#
|
||||
# Env (.env): PORT, DEPLOY_TOKEN, ALLOWED_SLUGS
|
||||
#
|
||||
# Note: provision.sh intentionally skips certbot. SSL is issued via POST /ssl so
|
||||
|
||||
Executable
+61
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
# Insert Meshkee SEO proxy locations (/sitemap.xml, /robots.txt) into an existing storefront nginx site.
|
||||
set -euo pipefail
|
||||
|
||||
HOST="${1:-}"
|
||||
API_HOST="${MESHKEE_API_HOST:-api.meshkee.com}"
|
||||
|
||||
if [[ -z "$HOST" ]]; then
|
||||
echo "usage: patch-nginx-seo.sh <host>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NGINX_AVAILABLE="/etc/nginx/sites-available/$HOST"
|
||||
|
||||
if [[ ! -f "$NGINX_AVAILABLE" ]]; then
|
||||
echo "missing nginx site for $HOST" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if grep -q 'location = /sitemap.xml' "$NGINX_AVAILABLE"; then
|
||||
echo "nginx SEO locations already present for $HOST"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
TMP="$(mktemp)"
|
||||
SEO_BLOCK="$(cat <<NGINX
|
||||
location = /sitemap.xml {
|
||||
proxy_pass https://${API_HOST}/api/v1/tenants/${HOST}/sitemap.xml;
|
||||
proxy_set_header Host ${API_HOST};
|
||||
proxy_ssl_server_name on;
|
||||
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;
|
||||
add_header Cache-Control "public, max-age=900";
|
||||
}
|
||||
|
||||
location = /robots.txt {
|
||||
proxy_pass https://${API_HOST}/api/v1/tenants/${HOST}/robots.txt;
|
||||
proxy_set_header Host ${API_HOST};
|
||||
proxy_ssl_server_name on;
|
||||
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;
|
||||
add_header Cache-Control "public, max-age=900";
|
||||
}
|
||||
|
||||
NGINX
|
||||
)"
|
||||
|
||||
awk -v block="$SEO_BLOCK" '
|
||||
/location \/ \{/ && !done {
|
||||
print block
|
||||
done = 1
|
||||
}
|
||||
{ print }
|
||||
' "$NGINX_AVAILABLE" >"$TMP"
|
||||
|
||||
mv "$TMP" "$NGINX_AVAILABLE"
|
||||
nginx -t
|
||||
systemctl reload nginx
|
||||
echo "patched nginx SEO locations for $HOST"
|
||||
@@ -122,6 +122,26 @@ server {
|
||||
listen [::]:80;
|
||||
server_name ${HOST} www.${HOST};
|
||||
|
||||
location = /sitemap.xml {
|
||||
proxy_pass https://api.meshkee.com/api/v1/tenants/${HOST}/sitemap.xml;
|
||||
proxy_set_header Host api.meshkee.com;
|
||||
proxy_ssl_server_name on;
|
||||
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;
|
||||
add_header Cache-Control "public, max-age=900";
|
||||
}
|
||||
|
||||
location = /robots.txt {
|
||||
proxy_pass https://api.meshkee.com/api/v1/tenants/${HOST}/robots.txt;
|
||||
proxy_set_header Host api.meshkee.com;
|
||||
proxy_ssl_server_name on;
|
||||
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;
|
||||
add_header Cache-Control "public, max-age=900";
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:${PORT};
|
||||
proxy_http_version 1.1;
|
||||
@@ -141,6 +161,10 @@ NGINX
|
||||
echo "nginx site created for $HOST → :$PORT"
|
||||
else
|
||||
echo "nginx site already exists: $NGINX_AVAILABLE"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
if [[ -x "$SCRIPT_DIR/patch-nginx-seo.sh" ]]; then
|
||||
"$SCRIPT_DIR/patch-nginx-seo.sh" "$HOST" || true
|
||||
fi
|
||||
fi
|
||||
|
||||
# SSL is issued separately via ssl.sh / Super Admin "Issue SSL" — do not run
|
||||
|
||||
Reference in New Issue
Block a user