Custom Domain
Configure a custom domain for your Uranus deployment.
Overview
Uranus can be deployed to a custom domain via:
- Cloudflare Workers Routes
- Cloudflare Pages Custom Domain
Workers Routes
1. Add Domain to Cloudflare
- Go to Cloudflare Dashboard
- Add your domain
- Update nameservers at registrar
- Wait for propagation
2. Configure Route
In wrangler.toml:
toml
routes = [
{ pattern = "manage.yourdomain.com/*", zone_name = "yourdomain.com" }
]Or multiple routes:
toml
routes = [
{ pattern = "manage.yourdomain.com/*", zone_name = "yourdomain.com" },
{ pattern = "api.yourdomain.com/*", zone_name = "yourdomain.com" }
]3. Deploy
bash
npm run deploy4. Verify
Visit https://manage.yourdomain.com
DNS Configuration
A Record (Proxied)
| Type | Name | Content | Proxy |
|---|---|---|---|
| A | manage | 192.0.2.1 | Yes |
AAAA Record (Proxied)
| Type | Name | Content | Proxy |
|---|---|---|---|
| AAAA | manage | 100:: | Yes |
The IP addresses are placeholders. Cloudflare will route traffic to your Worker.
SSL/TLS
Automatic SSL
Cloudflare provides automatic SSL:
- Full (strict) recommended
- Edge certificates included
- Origin certificates available
Configure SSL Mode
- Go to SSL/TLS in Cloudflare Dashboard
- Select "Full (strict)"
- Enable "Always Use HTTPS"
CORS Configuration
For cross-origin access:
typescript
const corsHeaders = {
'Access-Control-Allow-Origin': 'https://yourdomain.com',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
}Subdomain Setup
Multiple Subdomains
toml
routes = [
{ pattern = "manage.yourdomain.com/*", zone_name = "yourdomain.com" },
{ pattern = "api.yourdomain.com/*", zone_name = "yourdomain.com" },
{ pattern = "app.yourdomain.com/*", zone_name = "yourdomain.com" }
]Environment-Specific
toml
# Production
[env.production]
routes = [
{ pattern = "manage.yourdomain.com/*", zone_name = "yourdomain.com" }
]
# Staging
[env.staging]
routes = [
{ pattern = "staging.yourdomain.com/*", zone_name = "yourdomain.com" }
]Cloudflare Pages Domain
Alternatively, use Pages custom domains:
1. Deploy to Pages
bash
npx wrangler pages deploy dist2. Add Custom Domain
- Go to Pages project
- Custom domains
- Add domain
- Configure DNS
WebSocket Domain
WebSocket connections use the same domain:
javascript
const ws = new WebSocket('wss://manage.yourdomain.com/agent/my-agent')Redirects
www to non-www
Create a Page Rule:
- Go to Rules > Page Rules
- Add rule:
- URL:
www.yourdomain.com/* - Setting: Forwarding URL (301)
- Destination:
https://yourdomain.com/$1
- URL:
HTTP to HTTPS
Enable "Always Use HTTPS" in SSL/TLS settings.
Cache Configuration
Static Assets
toml
[site]
bucket = "./dist"
# Cache static assets
[[rules]]
type = "cache_ttl"
paths = ["/assets/*"]
edge_ttl = 86400
browser_ttl = 86400API Bypass
typescript
// Ensure API responses aren't cached
return new Response(body, {
headers: {
'Cache-Control': 'no-store'
}
})Firewall Rules
Rate Limiting
- Go to Security > WAF > Rate limiting
- Create rule for API endpoints
- Set threshold (e.g., 100 req/min)
Access Control
Block specific IPs or regions:
- Go to Security > WAF > Tools
- Create IP Access Rules
- Block or challenge as needed
Monitoring
Analytics
Enable Workers Analytics:
toml
[observability]
enabled = trueLogs
View access logs:
bash
npx wrangler tailTroubleshooting
Domain Not Resolving
- Verify DNS propagation
- Check proxy status (orange cloud)
- Confirm route configuration
SSL Errors
- Verify SSL mode (Full strict)
- Check certificate validity
- Ensure HTTPS redirect
1000 Error
- Check Worker deployment
- Verify route matches
- Review error logs
523 Origin Unreachable
- Ensure Worker is deployed
- Check route configuration
- Verify zone matches
Best Practices
1. Use Proxy Mode
Always enable Cloudflare proxy (orange cloud) for:
- DDoS protection
- SSL/TLS
- Caching
- Analytics
2. Enable Security Features
- WAF rules
- Rate limiting
- Bot management
- IP access rules
3. Configure Caching
- Cache static assets
- Bypass cache for API
- Set appropriate TTLs
4. Monitor Performance
- Enable Analytics
- Set up alerts
- Review logs regularly