From 0b461546961d84c6dc20c9e926b1b295623d5d4d Mon Sep 17 00:00:00 2001 From: elpatron Date: Fri, 12 Jun 2026 10:58:21 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20robots.txt,=20Sitemap=20und=20Staging-n?= =?UTF-8?q?oindex=20f=C3=BCr=20SEO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Google Search Console: echte robots.txt und sitemap.xml für Produktion; Staging blockiert Crawler per X-Robots-Tag und Disallow in robots.txt. Co-authored-by: Cursor --- .env.example | 5 +++++ client/docker-entrypoint.sh | 16 +++++++++++++++- client/nginx.conf.template | 1 + client/public/robots.txt | 4 ++++ client/public/sitemap.xml | 8 ++++++++ docker-compose.staging.yml | 1 + docs/deployment/staging.md | 2 +- 7 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 client/public/robots.txt create mode 100644 client/public/sitemap.xml diff --git a/.env.example b/.env.example index 426e2ca..9da0696 100755 --- a/.env.example +++ b/.env.example @@ -64,3 +64,8 @@ NTFY_TOKEN=tk_example_ntfy_access_token # Staging: PLAUSIBLE_ENABLED=false (default in docker-compose.staging.yml) PLAUSIBLE_ENABLED=true PLAUSIBLE_HOST=https://plausible.elpatron.me + +# SEO (frontend container — robots.txt, X-Robots-Tag) +# Production: ROBOTS_NOINDEX=false (default) +# Staging: ROBOTS_NOINDEX=true (default in docker-compose.staging.yml) +# ROBOTS_NOINDEX=false diff --git a/client/docker-entrypoint.sh b/client/docker-entrypoint.sh index 0b7ff3a..6fa6e5f 100755 --- a/client/docker-entrypoint.sh +++ b/client/docker-entrypoint.sh @@ -16,8 +16,22 @@ case "$(printf '%s' "$PLAUSIBLE_ENABLED" | tr '[:upper:]' '[:lower:]')" in ;; esac +ROBOTS_NOINDEX="${ROBOTS_NOINDEX:-false}" +case "$(printf '%s' "$ROBOTS_NOINDEX" | tr '[:upper:]' '[:lower:]')" in + true|1|yes) + export ROBOTS_NOINDEX_HEADER=' add_header X-Robots-Tag "noindex, nofollow" always;' + cat > /usr/share/nginx/html/robots.txt <<'EOF' +User-agent: * +Disallow: / +EOF + ;; + *) + export ROBOTS_NOINDEX_HEADER='' + ;; +esac + export PLAUSIBLE_CSP -envsubst '${PLAUSIBLE_CSP}' < /etc/nginx/templates/default.conf.template > /etc/nginx/conf.d/default.conf +envsubst '${PLAUSIBLE_CSP} ${ROBOTS_NOINDEX_HEADER}' < /etc/nginx/templates/default.conf.template > /etc/nginx/conf.d/default.conf cat > /usr/share/nginx/html/runtime-config.json < + + + https://kapteins-daagbok.eu/ + monthly + 1.0 + + diff --git a/docker-compose.staging.yml b/docker-compose.staging.yml index 69019e2..fc8b21c 100644 --- a/docker-compose.staging.yml +++ b/docker-compose.staging.yml @@ -60,6 +60,7 @@ services: environment: PLAUSIBLE_ENABLED: ${PLAUSIBLE_ENABLED:-false} PLAUSIBLE_HOST: ${PLAUSIBLE_HOST:-https://plausible.elpatron.me} + ROBOTS_NOINDEX: ${ROBOTS_NOINDEX:-true} ports: - "80:80" depends_on: diff --git a/docs/deployment/staging.md b/docs/deployment/staging.md index 7d420e6..c4cd5e7 100644 --- a/docs/deployment/staging.md +++ b/docs/deployment/staging.md @@ -83,7 +83,7 @@ Notfall ohne Checks: `SKIP_PREDEPLOY_CHECK=1 ./scripts/update-remotes.sh -dest s | Forward Port | `80` | | SSL | Let's Encrypt | -Empfohlen: Custom Header `X-Robots-Tag: noindex, nofollow` (Staging nicht indexieren). +Staging ist per Default nicht indexierbar: `ROBOTS_NOINDEX=true` im Frontend-Container setzt `X-Robots-Tag: noindex, nofollow` und liefert `robots.txt` mit `Disallow: /` (siehe `docker-compose.staging.yml`). Details zu Proxy-Headern und Security: [npm-security.md](npm-security.md).