Issue #1155: add robots.txt to both frontends; widen CloudFront invalidation - #1156
Open
bjagg wants to merge 1 commit into
Open
Issue #1155: add robots.txt to both frontends; widen CloudFront invalidation#1156bjagg wants to merge 1 commit into
bjagg wants to merge 1 commit into
Conversation
…oudFront invalidation Analytics is showing crawler/scan traffic against the dev and demo hosts. Neither frontend served a robots.txt, and because both use SPA fallback (`try_files $uri /index.html` in nginx; CloudFront 403/404 -> /index.html), a request for /robots.txt returned index.html with HTTP 200 rather than a 404 — so crawlers got a valid HTML page for every path they probed. Adds `public/robots.txt` to `frontends/mdr-frontend` and `frontends/lif_advisor_app`, disallowing all user-agents. These hosts serve non-production evaluation environments; nothing here belongs in a search index. One file per frontend covers both delivery paths, since Vite copies `public/` into `dist/` and both paths serve from the build output — `aws s3 sync --delete dist s3://...` for mdr-frontend, and nginx from `/usr/share/nginx/html` for the advisor app. Verified by building mdr-frontend and confirming `dist/robots.txt`. The files deliberately do not enumerate paths. A robots.txt listing routes advertises them to exactly the scanners this is meant to discourage. Each file also carries a note that robots.txt is advisory, so it isn't later mistaken for a security control. Also widens the mdr-frontend CloudFront invalidation from `--paths "/"` to `--paths "/*"`. Without this the new file would not become visible: the deploy replaces the whole object set via `s3 sync --delete`, but stable-named files (index.html, robots.txt) keep serving from the edge cache. Hashed asset filenames cache-bust themselves; these do not. Refs LIF-Initiative#1155 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
Analytics is showing crawler/scan traffic against the dev and demo hosts, and neither frontend served a
robots.txt.Because both frontends use SPA fallback,
/robots.txtcurrently returnsindex.htmlwith HTTP 200, not a 404 —try_files $uri /index.htmlinfrontends/*/nginx.conf, andcloudformation/s3-hosted.yml:82-88mapping CloudFront 403/404 to/index.htmlwithResponseCode: 200. A crawler probing arbitrary paths gets a valid HTML page every time.Adds
public/robots.txtto both frontends, disallowing all user-agents. These hosts serve non-production evaluation environments; nothing here belongs in a search index, so there's no SEO value to weigh against a blanket disallow.One file per frontend covers both delivery paths, because Vite copies
public/intodist/and both paths serve the build output:dist/robots.txtviaaws s3 sync --delete dist s3://...root /usr/share/nginx/html+try_files $uriVerified by building mdr-frontend and confirming
dist/robots.txt(590 bytes) lands in the sync root.Also widens the CloudFront invalidation from
--paths "/"to--paths "/*"in.github/workflows/lif_mdr_frontend.yml. Without this the new file would not become visible: the deploy replaces the whole object set vias3 sync --delete, but stable-named files (index.html,robots.txt) keep serving from the edge cache. Hashed asset filenames cache-bust themselves; these do not. Happy to split this into its own PR if you'd rather keep them separate — but as it stands the robots.txt wouldn't take effect on demo without it.Two deliberate choices
No path enumeration. The file lists no routes. A
robots.txtenumerating paths advertises them to exactly the scanners this is meant to discourage.An explicit note that it's advisory. Each file records that well-behaved crawlers honor
robots.txtand scanners ignore it, so it isn't later mistaken for a security control.What this does not fix — worth reading before closing #1155
robots.txtonly influences well-behaved crawlers. If the analytics traffic is probing for/.env,/wp-admin,/.git/configand similar, this change will not reduce it at all — that needs WAF rules, rate limiting, or blocking at CloudFront/ALB. Worth confirming from the analytics data which pattern this actually is, since that determines whether this is the fix or just hygiene.Separately flagged in #1155: both the MDR API and the LDE API construct
FastAPI(...)with defaults and explicitly allowlist/docsand/openapi.jsonunauthenticated, so the full API surface is publicly readable on dev/demo. A published OpenAPI spec is a high-value scanning target, androbots.txtdoes nothing for it. That deserves its own decision rather than being bundled here.Related Issues
Closes #1155
Type of Change
Project Area(s) Affected
Checklist
Testing
npm run build(mdr-frontend)dist/robots.txtpresent in sync rootpublicDiroverridden in either vite configpublic/→dist/pre-commit run --files <3 changed>Not verified end-to-end against a deployed host — that needs a deploy. After merge, confirm
curl -sI https://mdr.dev.lif.unicon.net/robots.txtreturnstext/plainrather thantext/html.Additional Notes
Staged three explicit paths only; the working tree has unrelated untracked files.
dist/is gitignored, so no build output is included.