Custom Domain Setup
Setting up a custom domain for your Dockit documentation site helps establish your brand identity and provides a professional appearance. This guide covers the complete process of configuring custom domains across different hosting platforms.
Overview
Section titled “Overview”A custom domain allows you to serve your documentation from your own branded URL instead of the default hosting provider subdomain. For example:
- Default:
your-docs.netlify.apporyour-docs.vercel.app - Custom:
docs.yourcompany.comorhelp.yourcompany.com
Prerequisites
Section titled “Prerequisites”Before setting up a custom domain, ensure you have:
- Domain ownership: You own or control the domain you want to use
- DNS access: Ability to modify DNS records for your domain
- Deployed site: Your Dockit site is already deployed and working
- SSL certificate: HTTPS support (usually provided automatically)
Domain Configuration Options
Section titled “Domain Configuration Options”Subdomain Setup (Recommended)
Section titled “Subdomain Setup (Recommended)”Using a subdomain is the most common and recommended approach:
docs.yourcompany.comhelp.yourcompany.comsupport.yourcompany.comknowledge.yourcompany.comRoot Domain Setup
Section titled “Root Domain Setup”You can also use your root domain, though this requires additional considerations:
yourcompany.comyourdocs.comPath-based Setup
Section titled “Path-based Setup”Serve documentation from a specific path:
yourcompany.com/docsyourcompany.com/helpPlatform-Specific Setup
Section titled “Platform-Specific Setup”Netlify Configuration
Section titled “Netlify Configuration”Step 1: Add Custom Domain in Netlify
Section titled “Step 1: Add Custom Domain in Netlify”- Go to your site’s Site Settings in Netlify dashboard
- Navigate to Domain management → Custom domains
- Click Add custom domain
- Enter your domain (e.g.,
docs.yourcompany.com)
Step 2: Configure DNS Records
Section titled “Step 2: Configure DNS Records”Add a CNAME record in your DNS provider:
Type: CNAMEName: docs (or your chosen subdomain)Value: your-site-name.netlify.appTTL: 3600 (or Auto)Step 3: Enable HTTPS
Section titled “Step 3: Enable HTTPS”Netlify automatically provisions SSL certificates through Let’s Encrypt:
- Wait for DNS propagation (up to 24 hours)
- SSL certificate will be automatically issued
- Force HTTPS redirect in Site Settings → HTTPS
Step 4: Configure _redirects (Optional)
Section titled “Step 4: Configure _redirects (Optional)”Create a _redirects file in your public/ directory:
# Force HTTPShttp://docs.yourcompany.com/* https://docs.yourcompany.com/:splat 301!
# Redirect old paths/old-docs/* /new-docs/:splat 301/v1/* /latest/:splat 301
# SPA fallback/* /index.html 200Vercel Configuration
Section titled “Vercel Configuration”Step 1: Add Domain in Vercel
Section titled “Step 1: Add Domain in Vercel”- Go to your project dashboard
- Navigate to Settings → Domains
- Enter your custom domain
- Choose the deployment branch
Step 2: Configure DNS
Section titled “Step 2: Configure DNS”For subdomains, add a CNAME record:
Type: CNAMEName: docsValue: cname.vercel-dns.comFor root domains, add A records:
Type: AName: @Value: 76.76.19.61
Type: AName: @Value: 76.76.19.62Step 3: Verify Domain
Section titled “Step 3: Verify Domain”Vercel will automatically verify your domain and issue SSL certificates.
Step 4: Configure vercel.json
Section titled “Step 4: Configure vercel.json”{ "redirects": [ { "source": "/old-path", "destination": "/new-path", "permanent": true } ], "headers": [ { "source": "/(.*)", "headers": [ { "key": "X-Content-Type-Options", "value": "nosniff" }, { "key": "X-Frame-Options", "value": "DENY" }, { "key": "X-XSS-Protection", "value": "1; mode=block" } ] } ]}GitHub Pages Configuration
Section titled “GitHub Pages Configuration”Step 1: Configure Repository Settings
Section titled “Step 1: Configure Repository Settings”- Go to repository Settings → Pages
- Select source (usually
mainbranch) - Add custom domain in the Custom domain field
Step 2: Create CNAME File
Section titled “Step 2: Create CNAME File”Create a CNAME file in your repository root or public/ directory:
docs.yourcompany.comStep 3: Configure DNS
Section titled “Step 3: Configure DNS”Add a CNAME record pointing to GitHub Pages:
Type: CNAMEName: docsValue: yourusername.github.ioStep 4: Enable HTTPS
Section titled “Step 4: Enable HTTPS”GitHub Pages automatically provides SSL certificates for custom domains.
Firebase Hosting Configuration
Section titled “Firebase Hosting Configuration”Step 1: Configure firebase.json
Section titled “Step 1: Configure firebase.json”{ "hosting": { "public": "dist", "site": "your-project-id", "cleanUrls": true, "trailingSlash": false, "rewrites": [ { "source": "**", "destination": "/index.html" } ], "headers": [ { "source": "**/*.@(jpg|jpeg|gif|png|svg|webp|js|css)", "headers": [ { "key": "Cache-Control", "value": "max-age=31536000" } ] } ] }}Step 2: Add Custom Domain
Section titled “Step 2: Add Custom Domain”firebase hosting:channel:deploy live --only hostingfirebase hosting:site:get your-project-idAdd domain in Firebase Console:
- Go to Hosting section
- Click Add custom domain
- Follow the verification steps
Step 3: DNS Configuration
Section titled “Step 3: DNS Configuration”Add the provided DNS records from Firebase Console.
DNS Provider Examples
Section titled “DNS Provider Examples”Cloudflare DNS
Section titled “Cloudflare DNS”Type: CNAMEName: docsContent: your-site.netlify.appProxy status: Proxied (orange cloud)TTL: AutoAdditional Cloudflare settings:
- SSL/TLS: Full (strict)
- Always Use HTTPS: On
- Automatic HTTPS Rewrites: On
Google Domains
Section titled “Google Domains”Type: CNAMEName: docsData: your-site.netlify.app.TTL: 1 hourNamecheap DNS
Section titled “Namecheap DNS”Type: CNAME RecordHost: docsValue: your-site.netlify.appTTL: AutomaticRoute 53 (AWS)
Section titled “Route 53 (AWS)”{ "Type": "CNAME", "Name": "docs.yourcompany.com", "Value": "your-site.netlify.app", "TTL": 300}SSL Certificate Configuration
Section titled “SSL Certificate Configuration”Automatic SSL (Recommended)
Section titled “Automatic SSL (Recommended)”Most modern hosting platforms provide automatic SSL:
- Netlify: Let’s Encrypt (automatic)
- Vercel: Automatic SSL provisioning
- GitHub Pages: Automatic for custom domains
- Firebase: Google-managed certificates
Manual SSL Configuration
Section titled “Manual SSL Configuration”For advanced setups, you might need manual SSL configuration:
server { listen 443 ssl http2; server_name docs.yourcompany.com;
ssl_certificate /path/to/certificate.crt; ssl_certificate_key /path/to/private.key;
ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512; ssl_prefer_server_ciphers off;
location / { proxy_pass http://localhost:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; }}Advanced Configuration
Section titled “Advanced Configuration”Multiple Domains
Section titled “Multiple Domains”Configure multiple domains for the same site:
[[redirects]] from = "https://old-docs.com/*" to = "https://docs.yourcompany.com/:splat" status = 301 force = true
[[redirects]] from = "https://help.yourcompany.com/*" to = "https://docs.yourcompany.com/:splat" status = 301 force = trueInternationalization Domains
Section titled “Internationalization Domains”Set up different domains for different languages:
docs.yourcompany.com (English)docs-de.yourcompany.com (German)docs-fr.yourcompany.com (French)docs-es.yourcompany.com (Spanish)CDN Integration
Section titled “CDN Integration”Configure CDN for better performance:
{ "functions": { "app/api/**/*.js": { "maxDuration": 30 } }, "regions": ["iad1", "sfo1", "fra1"], "github": { "enabled": false }}Security Best Practices
Section titled “Security Best Practices”HSTS Configuration
Section titled “HSTS Configuration”Enable HTTP Strict Transport Security:
Strict-Transport-Security: max-age=31536000; includeSubDomains; preloadContent Security Policy
Section titled “Content Security Policy”Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'; media-src 'self'; object-src 'none'; child-src 'self'; frame-ancestors 'none'; form-action 'self'; base-uri 'self';Additional Security Headers
Section titled “Additional Security Headers”X-Content-Type-Options: nosniffX-Frame-Options: DENYX-XSS-Protection: 1; mode=blockReferrer-Policy: strict-origin-when-cross-originPermissions-Policy: geolocation=(), microphone=(), camera=()Performance Optimization
Section titled “Performance Optimization”DNS Optimization
Section titled “DNS Optimization”- Use fast DNS providers: Cloudflare, Route 53, or Google DNS
- Minimize DNS lookups: Reduce external resource dependencies
- Enable DNS prefetching:
<link rel="dns-prefetch" href="//example.com">
Caching Strategy
Section titled “Caching Strategy”# Static assetsCache-Control: public, max-age=31536000, immutable
# HTML filesCache-Control: public, max-age=0, must-revalidate
# API responsesCache-Control: public, max-age=300, s-maxage=600Monitoring and Analytics
Section titled “Monitoring and Analytics”Domain Health Monitoring
Section titled “Domain Health Monitoring”Set up monitoring for your custom domain:
// Basic uptime monitoringasync function checkDomainHealth() { try { const response = await fetch('https://docs.yourcompany.com/health'); if (response.ok) { console.log('Domain is healthy'); } else { console.error('Domain health check failed'); } } catch (error) { console.error('Domain is unreachable:', error); }}
setInterval(checkDomainHealth, 300000); // Check every 5 minutesAnalytics Configuration
Section titled “Analytics Configuration”<!-- Google Analytics --><script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script><script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'GA_TRACKING_ID', { custom_map: { 'custom_parameter': 'dimension1' } });</script>Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”DNS Propagation Delays
Section titled “DNS Propagation Delays”DNS changes can take up to 48 hours to fully propagate worldwide:
# Check DNS propagationdig docs.yourcompany.comnslookup docs.yourcompany.comOnline tools:
- whatsmydns.net
- dnschecker.org
SSL Certificate Issues
Section titled “SSL Certificate Issues”Common SSL problems and solutions:
- Mixed content errors: Ensure all resources use HTTPS
- Certificate mismatch: Verify domain names match certificate
- Expired certificates: Set up auto-renewal
Redirect Loops
Section titled “Redirect Loops”Prevent infinite redirects:
# Incorrecthttps://docs.yourcompany.com → https://docs.yourcompany.com
# Correcthttp://docs.yourcompany.com → https://docs.yourcompany.comPerformance Issues
Section titled “Performance Issues”Diagnose and fix performance problems:
# Test site speedcurl -w "@curl-format.txt" -o /dev/null -s "https://docs.yourcompany.com"
# Check response headerscurl -I "https://docs.yourcompany.com"Debug Tools
Section titled “Debug Tools”DNS Debugging
Section titled “DNS Debugging”# Check A recordsdig A docs.yourcompany.com
# Check CNAME recordsdig CNAME docs.yourcompany.com
# Check MX recordsdig MX yourcompany.com
# Trace DNS resolutiondig +trace docs.yourcompany.comSSL Debugging
Section titled “SSL Debugging”# Check SSL certificateopenssl s_client -connect docs.yourcompany.com:443 -servername docs.yourcompany.com
# Test SSL configurationcurl -vI https://docs.yourcompany.comMigration Strategies
Section titled “Migration Strategies”Zero-Downtime Migration
Section titled “Zero-Downtime Migration”Plan for seamless domain migration:
- Prepare new domain: Set up and test thoroughly
- Update DNS with low TTL: Reduce propagation time
- Monitor traffic: Watch for any issues
- Implement redirects: Guide users to new domain
- Update internal links: Change all references
- Notify users: Communicate the change
Migration Checklist
Section titled “Migration Checklist”- Domain ownership verified
- DNS records configured
- SSL certificate active
- Redirects implemented
- Internal links updated
- External references notified
- Analytics tracking updated
- SEO considerations addressed
- Monitoring alerts configured
- Rollback plan prepared
Best Practices
Section titled “Best Practices”- Choose meaningful subdomains: Use clear, descriptive names
- Enable HTTPS everywhere: Never serve content over HTTP
- Monitor domain health: Set up uptime monitoring
- Plan for disasters: Have backup domains ready
- Document your setup: Keep configuration records
- Regular maintenance: Review and update configurations
- Security first: Implement proper headers and policies
- Performance matters: Optimize for speed and reliability
Conclusion
Section titled “Conclusion”Setting up a custom domain for your Dockit documentation site enhances your brand presence and provides a professional experience for your users. Follow the platform-specific instructions, implement proper security measures, and monitor your domain’s health for the best results.
Remember to test thoroughly in a staging environment before making changes to production domains, and always have a rollback plan ready in case of issues.