ArcArcGo: DuckDuckGo Proxy with Custom Branding
GitHub: 0xarchit/ArcArcGo
Live Demo: https://arcarcgo.0xarchit.is-a.dev
Tip
ArcArcGo is a Cloudflare Worker that acts as a transparent proxy for DuckDuckGo, implementing custom branding and URL rewriting through regex patterns and JavaScript injection.
Screenshot
Overview
ArcArcGo demonstrates advanced Cloudflare Workers capabilities by intercepting requests, fetching content from DuckDuckGo, and modifying responses before serving them to clients with custom branding and functionality.
Architecture
Request Flow
- Client Request → Cloudflare Worker
- Worker Processing → DuckDuckGo Server
- Response Modification → Client
graph LR
A[Client] --> B[Cloudflare Worker]
B --> C[DuckDuckGo]
C --> B
B --> A
B -.-> D[URL Rewriting + Branding]Core Components
1. Event Listener
The worker uses a fetch event listener to intercept all incoming HTTP requests and delegates processing to the main handleRequest function.
2. Request Handler (handleRequest)
URL Construction
The worker extracts the pathname, search parameters, and hash from incoming requests and constructs the target DuckDuckGo URL while maintaining the original query structure.
Header Processing
Header Modifications:
- Removed:
Host,X-Forwarded-For(prevents detection as proxy) - Set: Standard browser
Acceptheader - Set: Default
User-Agentif not present
Response Processing
Response Header Modifications:
- Removed:
Content-Security-Policy(allows script injection) - Added: CORS header for cross-origin access
3. Content Type Handling
Non-HTML Content
Images, CSS, JavaScript, and other assets are passed through unchanged, maintaining original response body and headers.
HTML Content Processing
Uses TransformStream for real-time content modification without buffering the entire response.
URL Rewriting System
Pattern Matching
The worker uses comprehensive regex patterns to identify and rewrite URLs, including:
- Standard HTML attributes:
href,src,actionin both double and single quotes - CSS URLs:
url()declarations - Meta refresh: URL redirects in meta tags
- JavaScript redirects:
window.location,location.href, etc. - Data attributes: Custom data URLs for navigation
- Absolute paths: Standalone paths in quotes
- Event handlers:
onclick,onchange,onsubmitattributes
URL Transformation Logic
1. Absolute URLs
Only processes DuckDuckGo URLs by stripping the domain and prepending the proxy base URL.
2. Relative URLs
Resolves relative URLs against the DuckDuckGo origin while maintaining query parameters.
3. Special Cases
- Fragments (#): Preserved unchanged
- Data URLs: Preserved unchanged
- JavaScript URLs: Preserved unchanged
- Event Handlers: Special processing for location changes
Branding System
Text Replacement
Real-time text replacement in HTML content using regex patterns to replace "DuckDuckGo" with "ArcArcGo" and handle possessive forms.
Logo Replacement
Regex-based logo replacement that identifies DuckDuckGo logo images and replaces them with the custom ArcArcGo logo.
JavaScript Injection
Dynamic branding through injected script that:
- Text Replacement: Uses TreeWalker to traverse all text nodes
- Title Replacement: Updates document title
- Logo Replacement: Targets specific CSS selectors for logo images
- Dynamic Monitoring: Uses MutationObserver for continuously added content
- Multiple Triggers: Responds to load, DOMContentLoaded events, and periodic intervals
Stream Processing
Chunked Processing
The worker processes content in chunks to optimize memory usage and provide real-time response modification. It uses a buffer system with:
Buffer Management:
- Size Threshold: 8192 bytes
- Content Threshold: Presence of
</body>tag - Final Processing: Script injection before response completion
Error Handling
The worker implements comprehensive error handling for:
- Network connectivity issues
- Invalid URL construction
- Stream processing errors
- Regex processing failures
All errors return a 500 status response with a descriptive error message.
Performance Considerations
Optimization Strategies
- Selective Processing: Only HTML content is modified
- Chunked Streaming: Real-time processing without buffering entire response
- Efficient Regex: Compiled patterns for fast matching
- Header Optimization: Minimal header modifications
Resource Usage
- Memory: Stream-based processing minimizes memory usage
- CPU: Regex operations on text chunks
- Network: Direct proxy with minimal latency
Security Considerations
Mitigations Implemented
- CSP Removal: Enables script injection
- Header Sanitization: Removes tracking headers
- URL Validation: Prevents open proxy attacks
- Content Filtering: Only processes specific content types
Potential Risks
- Open Proxy: Limited to DuckDuckGo domain
- Script Injection: Controlled injection for branding only
- Privacy: No logging or data collection
Deployment Guide
Prerequisites
- Cloudflare account
- Workers subscription (free tier available)
Deployment Steps
- Create Worker: In Cloudflare dashboard
- Deploy Code: Copy
worker.jscontent - Configure Routes: Set custom domain or use workers.dev subdomain
- Test Functionality: Verify search and branding
Configuration Options
- Custom Logo: Modify
newLogoSrcvariable - Branding Text: Adjust replacement patterns
- Target Domain: Change
targetHostfor different proxy targets
Troubleshooting
Common Issues
1. Script Injection Not Working
- Cause: CSP blocking or timing issues
- Solution: Verify CSP removal, check MutationObserver
2. URLs Not Rewriting
- Cause: Pattern mismatch or encoding issues
- Solution: Test regex patterns, check URL encoding
3. Performance Issues
- Cause: Large content or complex patterns
- Solution: Optimize buffer size, simplify regex patterns
Debug Techniques
- Console Logging: Add logging to worker (remove in production)
- Network Inspection: Check headers and response codes
- Content Validation: Verify HTML modifications
Limitations
Technical Limitations
- JavaScript-Heavy Sites: May require additional pattern matching
- Dynamic Content: MutationObserver helps but may miss rapid changes
- Complex URLs: Some edge cases may not be covered
Legal Considerations
- Terms of Service: May violate target site's ToS
- Copyright: Logo and content modifications
- Educational Use: Intended for learning purposes only
Warning
Important Notice: This is not a clone or phishing page. This is an educational project created while exploring Cloudflare Workers and can be treated as a prototype for creating similar website proxies. It will be removed if it violates any ToS or is found to be illegal.
Contact: mail@0xarchit.is-a.dev
Conclusion
ArcArcGo demonstrates advanced Cloudflare Workers capabilities including:
- Real-time content transformation
- Complex regex-based URL rewriting
- Dynamic JavaScript injection
- Stream processing optimization
- Practical proxy server development
- Performance optimization techniques
- Maintaining functionality of underlying service
- Educational exploration of web proxy concepts
The implementation showcases how modern edge computing can be used to create sophisticated web proxies while maintaining the performance and functionality of the underlying service.