feat: Introduces bot-specific routing and static SEO page serving in Caddy#67
feat: Introduces bot-specific routing and static SEO page serving in Caddy#67
Conversation
WalkthroughIntroduces bot-specific routing and static SEO page serving in Caddy, separates bot vs human SPA handling with adjusted exclusions and headers, and mounts a new read-only SEO assets directory into Caddy containers via docker-compose. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client
participant Caddy
participant SEO_Files as /usr/share/caddy/seo
participant SPA as SPA/Static
Client->>Caddy: HTTP Request (path, User-Agent)
alt UA matches share/social bots (@sharebots)
note over Caddy: Bot flow (new)
Caddy->>SEO_Files: Lookup /seo/*.seo.html
SEO_Files-->>Caddy: File (if exists)
Caddy-->>Client: 200 SEO HTML + security headers
opt Missing SEO file
Caddy-->>Client: 404
end
else Non-bot (humans)
note over Caddy: SPA flow with exclusions<br/>(excludes /seo/*, /relay/*, assets)
Caddy->>SPA: Serve SPA or static assets
Caddy-->>Client: 200 with caching + Vary: User-Agent
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
caddy/WebCaddyfile.internal (1)
54-54: Consider adding more social media bots to the regex pattern.The current regex covers major search engines and social platforms, but you may want to include additional bots commonly used for link previews and social sharing.
Based on the search results, you may want to consider adding additional bot user agents commonly used for link previews and social sharing. Here are some notable ones that could be added to your regex pattern:
- iframely - commonly used for link previews
- redditbot - for Reddit link previews
- mastodon - for Mastodon social platform
- applebot - for Apple ecosystem link previews
- amazonbot - for Amazon's services
- bingpreview - for Microsoft services beyond Bing search
Consider updating your regex to include these additional patterns:
-@sharebots header_regexp ua User-Agent "(?i)(googlebot|bingbot|duckduckbot|yandex(bot|images)|baiduspider|facebookexternalhit|twitterbot|linkedinbot|slackbot|telegrambot|discordbot|pinterest|whatsapp|skypeuripreview|bitlybot|vkshare|quora link preview|embedly|outbrain|nuzzel|ios link preview|snapchat|applebot)" +@sharebots header_regexp ua User-Agent "(?i)(googlebot|bingbot|duckduckbot|yandex(bot|images)|baiduspider|facebookexternalhit|twitterbot|linkedinbot|slackbot|telegrambot|discordbot|pinterest|whatsapp|skypeuripreview|bitlybot|vkshare|quora link preview|embedly|outbrain|nuzzel|ios link preview|snapchat|applebot|iframely|redditbot|mastodon|amazonbot|bingpreview)"Based on search results showing common social media bot user agents in 2024-2025.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
caddy/WebCaddyfile.internal(2 hunks)docker-compose.yml(2 hunks)
🔇 Additional comments (4)
docker-compose.yml (1)
36-36: LGTM! SEO volume mounts correctly configured.The read-only SEO asset mounts are properly configured for both local and production environments, supporting the new bot-specific routing functionality introduced in the Caddy configuration.
Also applies to: 64-64
caddy/WebCaddyfile.internal (3)
55-100: LGTM! Well-structured bot handling with proper fallback.The bot handling logic is well-implemented with:
- Proper try_files sequence with SEO file fallbacks
- Appropriate caching headers for different asset types
- Security headers applied to bot responses
- Consistent compression settings
103-135: LGTM! Human SPA handling is correctly implemented.The human SPA handling provides:
- Clean fallback to SPA for non-bot traffic
- Consistent caching strategies matching the bot path
- Proper security headers
- Appropriate User-Agent variance handling
84-84: Good addition of /relay/ exclusion.*Adding
/relay/*to the @html exclusion list is appropriate since these paths are handled by the reverse proxy configuration and shouldn't receive HTML caching headers.Also applies to: 121-121
Summary by CodeRabbit