How to configure custom domains and SSL certificates on Vercel?
Configuring custom domains and SSL certificates on Vercel is a straightforward process. Vercel provides automated SSL certificate management, making this process very convenient.
Custom Domain Configuration
1. Adding Custom Domains
Adding via Vercel Dashboard:
- Log in to Vercel Dashboard
- Select your project
- Go to "Settings" → "Domains"
- Click "Add Domain"
- Enter your domain (e.g.,
example.comorwww.example.com) - Choose domain type:
- Production: For production environment
- Preview: For preview deployments
Adding via Vercel CLI:
bash# Add production domain vercel domains add example.com # Add preview domain vercel domains add preview.example.com --preview
2. Domain Types
Vercel supports the following domain types:
Root Domain:
example.com- Requires A record or CNAME alias record
Subdomain:
www.example.comblog.example.comapi.example.com- Uses CNAME record
Wildcard Domain:
*.example.com- Matches all subdomains
- Requires paid plan
3. DNS Configuration
Configuration Steps:
- Check DNS configuration requirements in Vercel Dashboard
- Log in to your domain registrar (e.g., GoDaddy, Namecheap, Cloudflare)
- Add appropriate DNS records based on type
A Record Configuration (for root domain):
shellType: A Name: @ Value: 76.76.21.21 TTL: 3600 (or default)
CNAME Record Configuration (for subdomain):
shellType: CNAME Name: www Value: cname.vercel-dns.com TTL: 3600 (or default)
Special Configuration with Cloudflare:
If you use Cloudflare as your DNS provider, note:
-
Proxy Mode:
- When Cloudflare proxy is enabled (orange cloud), Vercel may not correctly verify domain ownership
- Recommend disabling proxy (gray cloud) first, wait for verification, then enable
-
SSL Mode:
- Set to "Full" or "Full (strict)"
- Do not use "Flexible" mode
4. Domain Verification
Verification Process:
- After adding DNS records, Vercel automatically verifies domain configuration
- Verification typically takes a few minutes to a few hours (depending on DNS propagation)
- Once verified, domain status shows "Valid Configuration"
Verification Checks:
bash# Check if DNS records are effective dig example.com # Check CNAME record dig www.example.com CNAME # Check DNS propagation nslookup example.com
SSL Certificate Configuration
1. Automatic SSL Certificates
Vercel uses Let's Encrypt to automatically provide SSL certificates for your domains:
Features:
- Completely free
- Automatic renewal
- Supports HTTP/2 and HTTP/3
- Automatic configuration
Certificate Types:
- Single Domain Certificate: Protects a single domain
- Wildcard Certificate: Protects main domain and all its subdomains (requires paid plan)
2. Automatic SSL Certificate Management
Automatic Issuance:
- After domain verification passes, Vercel automatically issues SSL certificate
- Usually completes within minutes
- No manual operation required
Automatic Renewal:
- Certificates automatically renew 30 days before expiration
- No need to worry about certificate expiration
- Fully automated
Certificate Monitoring:
- Vercel continuously monitors certificate status
- Automatically fixes issues when discovered
- View certificate details in Dashboard
3. Force HTTPS
Automatic Redirect:
Vercel by default redirects all HTTP requests to HTTPS:
javascript// Configure in vercel.json { "redirects": [ { "source": "/:path*", "has": [ { "type": "host", "value": "example.com" } ], "destination": "https://example.com/:path*", "permanent": true } ] }
HSTS Configuration:
javascript{ "headers": [ { "source": "/(.*)", "headers": [ { "key": "Strict-Transport-Security", "value": "max-age=31536000; includeSubDomains" } ] } ] }
Advanced Configuration
1. Multiple Domain Configuration
Adding Multiple Domains:
- Add domains one by one in Domains settings
- Configure DNS records for each domain
- Wait for all domains to verify
Primary Domain Setting:
javascript// Set primary domain in vercel.json { "name": "my-project", "alias": ["example.com", "www.example.com"] }
2. Environment-Specific Domains
Preview Environment Domain:
bash# Add specific domain for preview deployments vercel domains add preview.example.com --preview
Development Environment Domain:
bash# Add domain for development environment vercel domains add dev.example.com --dev
3. Custom 404 Page
Configure Custom 404 Page:
javascript// Configure in vercel.json { "rewrites": [ { "source": "/404", "destination": "/custom-404.html" } ], "notFound": true }
Troubleshooting
1. Domain Verification Failed
Common Causes:
- DNS record configuration error
- DNS propagation not complete
- Domain already used by another service
- Cloudflare proxy mode issue
Solutions:
- Check if DNS records are correct
- Use DNS checking tools to verify records
- Wait for DNS propagation to complete (up to 48 hours)
- If using Cloudflare, temporarily disable proxy
bash# Check DNS records dig example.com +short # Check WHOIS information whois example.com # Check DNS propagation dig example.com @8.8.8.8
2. SSL Certificate Issuance Failed
Common Causes:
- Domain verification not passed
- DNS record configuration error
- Firewall blocking Let's Encrypt verification
- Domain already used by another certificate
Solutions:
- Ensure domain verification passed
- Check DNS record configuration
- Check firewall settings
- Manually trigger certificate re-issuance in Dashboard
3. HTTPS Redirect Not Working
Checklist:
- Confirm SSL certificate has been issued
- Check redirect settings in Vercel configuration
- Clear browser cache
- Test in private mode
Best Practices
1. Domain Management
- Use version control for domain configuration
- Regularly check domain expiration dates
- Set up auto-renewal for important domains
- Keep backup of domain access credentials
2. SSL Security
- Enable HSTS to force HTTPS
- Regularly check SSL certificate status
- Use strong passwords for domain accounts
- Enable two-factor authentication
3. Monitoring and Alerts
- Set up domain expiration reminders
- Monitor SSL certificate status
- Configure website availability monitoring
- Set up error alerts
4. Performance Optimization
- Use CDN to accelerate static resources
- Enable HTTP/2 and HTTP/3
- Optimize DNS resolution time
- Use modern TLS versions
Frequently Asked Questions
Q1: Can I use free domains?
A: Yes, Vercel supports any legal domain, including free domains. However, it's recommended to use paid domains for better stability and support.
Q2: Is there a limit on SSL certificates?
A: In the free plan, you can add unlimited domains to each project, and each domain automatically receives an SSL certificate.
Q3: How do I migrate an existing domain to Vercel?
A:
- Add domain in Vercel
- Update DNS records to point to Vercel
- Wait for DNS propagation
- Verify configuration is correct
Q4: Can I use my own SSL certificate?
A: Vercel does not support uploading custom SSL certificates; you must use the automatically issued Let's Encrypt certificates from Vercel.
Q5: How long does domain configuration take to take effect?
A: Typically takes a few minutes to a few hours, up to 48 hours maximum (DNS propagation time).
Summary
Main advantages of configuring custom domains and SSL certificates on Vercel:
- Automated: SSL certificates automatically issued and renewed
- Simple: Intuitive configuration interface
- Free: Let's Encrypt SSL certificates completely free
- Secure: Automatic HTTPS redirect
- Reliable: 99.99% uptime guarantee
By following the steps and best practices above, you can easily configure custom domains and SSL certificates on Vercel, providing a secure, professional access experience for your website.