Skip to content

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

  1. Go to Cloudflare Dashboard
  2. Add your domain
  3. Update nameservers at registrar
  4. 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 deploy

4. Verify

Visit https://manage.yourdomain.com

DNS Configuration

A Record (Proxied)

TypeNameContentProxy
Amanage192.0.2.1Yes

AAAA Record (Proxied)

TypeNameContentProxy
AAAAmanage100::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

  1. Go to SSL/TLS in Cloudflare Dashboard
  2. Select "Full (strict)"
  3. 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 dist

2. Add Custom Domain

  1. Go to Pages project
  2. Custom domains
  3. Add domain
  4. 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:

  1. Go to Rules > Page Rules
  2. Add rule:
    • URL: www.yourdomain.com/*
    • Setting: Forwarding URL (301)
    • Destination: https://yourdomain.com/$1

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 = 86400

API Bypass

typescript
// Ensure API responses aren't cached
return new Response(body, {
  headers: {
    'Cache-Control': 'no-store'
  }
})

Firewall Rules

Rate Limiting

  1. Go to Security > WAF > Rate limiting
  2. Create rule for API endpoints
  3. Set threshold (e.g., 100 req/min)

Access Control

Block specific IPs or regions:

  1. Go to Security > WAF > Tools
  2. Create IP Access Rules
  3. Block or challenge as needed

Monitoring

Analytics

Enable Workers Analytics:

toml
[observability]
enabled = true

Logs

View access logs:

bash
npx wrangler tail

Troubleshooting

Domain Not Resolving

  1. Verify DNS propagation
  2. Check proxy status (orange cloud)
  3. Confirm route configuration

SSL Errors

  1. Verify SSL mode (Full strict)
  2. Check certificate validity
  3. Ensure HTTPS redirect

1000 Error

  1. Check Worker deployment
  2. Verify route matches
  3. Review error logs

523 Origin Unreachable

  1. Ensure Worker is deployed
  2. Check route configuration
  3. 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

Released under the MIT License.