Split product sitemap and use Farsi category URLs with ids.
sitemap.xml is now an index of main + products; category loc paths use /products/category/{id}/{nameFaSlug} with a public by-id lookup for storefronts.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
c4367d8eb0
commit
ea40ae40d8
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Insert Meshkee SEO proxy locations (/sitemap.xml, /robots.txt) into an existing storefront nginx site.
|
||||
# Insert / update Meshkee SEO proxy locations on an existing storefront nginx site.
|
||||
# Covers: /sitemap.xml (index), /sitemap-main.xml, /sitemap-products.xml, /robots.txt
|
||||
set -euo pipefail
|
||||
|
||||
HOST="${1:-}"
|
||||
@@ -17,25 +18,12 @@ if [[ ! -f "$NGINX_AVAILABLE" ]]; then
|
||||
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_location() {
|
||||
local path="$1"
|
||||
local upstream="$2"
|
||||
cat <<NGINX
|
||||
location = ${path} {
|
||||
proxy_pass https://${API_HOST}/api/v1/tenants/${HOST}/${upstream};
|
||||
proxy_set_header Host ${API_HOST};
|
||||
proxy_ssl_server_name on;
|
||||
proxy_set_header X-Real-IP \$remote_addr;
|
||||
@@ -45,17 +33,36 @@ SEO_BLOCK="$(cat <<NGINX
|
||||
}
|
||||
|
||||
NGINX
|
||||
)"
|
||||
}
|
||||
|
||||
awk -v block="$SEO_BLOCK" '
|
||||
/location \/ \{/ && !done {
|
||||
print block
|
||||
done = 1
|
||||
}
|
||||
{ print }
|
||||
' "$NGINX_AVAILABLE" >"$TMP"
|
||||
ensure_location() {
|
||||
local path="$1"
|
||||
local upstream="$2"
|
||||
if grep -q "location = ${path}" "$NGINX_AVAILABLE"; then
|
||||
echo "already present: ${path}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
local block
|
||||
block="$(proxy_location "$path" "$upstream")"
|
||||
local tmp
|
||||
tmp="$(mktemp)"
|
||||
awk -v block="$block" '
|
||||
/location \/ \{/ && !done {
|
||||
print block
|
||||
done = 1
|
||||
}
|
||||
{ print }
|
||||
' "$NGINX_AVAILABLE" >"$tmp"
|
||||
mv "$tmp" "$NGINX_AVAILABLE"
|
||||
echo "added: ${path}"
|
||||
}
|
||||
|
||||
ensure_location /sitemap.xml sitemap.xml
|
||||
ensure_location /sitemap-main.xml sitemap-main.xml
|
||||
ensure_location /sitemap-products.xml sitemap-products.xml
|
||||
ensure_location /robots.txt robots.txt
|
||||
|
||||
mv "$TMP" "$NGINX_AVAILABLE"
|
||||
nginx -t
|
||||
systemctl reload nginx
|
||||
echo "patched nginx SEO locations for $HOST"
|
||||
|
||||
@@ -132,6 +132,26 @@ server {
|
||||
add_header Cache-Control "public, max-age=900";
|
||||
}
|
||||
|
||||
location = /sitemap-main.xml {
|
||||
proxy_pass https://api.meshkee.com/api/v1/tenants/${HOST}/sitemap-main.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 = /sitemap-products.xml {
|
||||
proxy_pass https://api.meshkee.com/api/v1/tenants/${HOST}/sitemap-products.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;
|
||||
|
||||
Reference in New Issue
Block a user