Domain & DNS
Proper domain and DNS configuration is essential for production TractStack deployments. This guide covers domain setup, DNS records, and troubleshooting.
Domain Requirements
Section titled “Domain Requirements”Single-Tenant Setup
Section titled “Single-Tenant Setup”- Primary domain:
yourdomain.com
- Optional www:
www.yourdomain.com
Multi-Tenant Setup
Section titled “Multi-Tenant Setup”- Primary domain:
yourdomain.com
- Wildcard support:
*.yourdomain.com
- Tenant subdomains:
tenant1.yourdomain.com
,tenant2.yourdomain.com
Custom Domains (Multi-Tenant)
Section titled “Custom Domains (Multi-Tenant)”- Tenant-specific:
tenant.example.com
- Branded domains:
customer-site.com
DNS Configuration
Section titled “DNS Configuration”Basic DNS Records
Section titled “Basic DNS Records”A Record (IPv4):
Type: AName: @Value: YOUR_SERVER_IPTTL: 300
AAAA Record (IPv6, if available):
Type: AAAAName: @Value: YOUR_IPV6_ADDRESSTTL: 300
CNAME Record (www subdomain):
Type: CNAMEName: wwwValue: yourdomain.comTTL: 300
Multi-Tenant DNS
Section titled “Multi-Tenant DNS”Wildcard A Record:
Type: AName: *Value: YOUR_SERVER_IPTTL: 300
This enables all subdomains (anything.yourdomain.com
) to resolve to your server.
SSL Certificate DNS (Let’s Encrypt)
Section titled “SSL Certificate DNS (Let’s Encrypt)”For SSL verification, you’ll need TXT records:
Manual verification:
Type: TXTName: _acme-challengeValue: [provided by certbot]TTL: 120
Cloudflare API (automatic): No manual DNS records needed - handled automatically.
DNS Provider Configuration
Section titled “DNS Provider Configuration”Cloudflare
Section titled “Cloudflare”Advantages:
- Free SSL certificates
- CDN and DDoS protection
- API for automatic SSL verification
- Advanced DNS features
Setup:
- Add domain to Cloudflare
- Update nameservers at your registrar
- Set DNS records as above
- Enable SSL (Full or Full Strict)
- Create API token for TractStack
Recommended settings:
SSL/TLS: Full (Strict)Always Use HTTPS: OnMinimum TLS Version: 1.2HSTS: Enabled
Route 53 (AWS)
Section titled “Route 53 (AWS)”Setup:
- Create hosted zone for your domain
- Update nameservers at registrar
- Add DNS records as above
Example records:
{ "Type": "A", "Name": "yourdomain.com", "AliasTarget": { "DNSName": "YOUR_SERVER_IP", "EvaluateTargetHealth": false }}
Google Cloud DNS
Section titled “Google Cloud DNS”Setup:
- Create DNS zone
- Add record sets
- Update nameservers
CLI example:
gcloud dns record-sets transaction start --zone=yourdomain-zonegcloud dns record-sets transaction add YOUR_SERVER_IP --name=yourdomain.com. --ttl=300 --type=A --zone=yourdomain-zonegcloud dns record-sets transaction execute --zone=yourdomain-zone
Domain Registration
Section titled “Domain Registration”Choosing a Registrar
Section titled “Choosing a Registrar”Recommended registrars:
- Namecheap: Good balance of features and price
- Google Domains: Simple, reliable
- Cloudflare: Wholesale pricing, integrated DNS
- Name.com: Full-featured with good support
Avoid:
- Registrars with poor DNS management
- Those with restrictive transfer policies
- Providers with poor uptime records
Domain Transfer
Section titled “Domain Transfer”Before transferring:
- Unlock domain at current registrar
- Get auth code (EPP code)
- Ensure domain not expired
- Update contact information
During transfer:
- Initiate transfer at new registrar
- Confirm via email
- Wait for completion (5-7 days)
- Update DNS if changing providers
SSL Certificate Setup
Section titled “SSL Certificate Setup”Automatic (Recommended)
Section titled “Automatic (Recommended)”Cloudflare DNS API:
# During installationsudo mkdir -p /root/.secrets/certbotecho "dns_cloudflare_api_token = YOUR_TOKEN" | sudo tee /root/.secrets/certbot/cloudflare.inisudo chmod 600 /root/.secrets/certbot/cloudflare.ini
Installation will automatically:
- Request wildcard certificate
- Configure nginx
- Set up automatic renewal
Manual DNS Verification
Section titled “Manual DNS Verification”Process:
- Run installer
- Add TXT records when prompted
- Verify propagation
- Continue installation
Check DNS propagation:
dig _acme-challenge.yourdomain.com TXTnslookup -type=TXT _acme-challenge.yourdomain.com
nginx Configuration
Section titled “nginx Configuration”TractStack automatically configures nginx with:
Single Domain Configuration
Section titled “Single Domain Configuration”server { listen 80; server_name yourdomain.com www.yourdomain.com; return 301 https://$server_name$request_uri;}
server { listen 443 ssl http2; server_name yourdomain.com www.yourdomain.com;
ssl_certificate /home/t8k/etc/letsencrypt/live/yourdomain.com/fullchain.pem; ssl_certificate_key /home/t8k/etc/letsencrypt/live/yourdomain.com/privkey.pem;
location / { proxy_pass http://127.0.0.1:20000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; }}
Multi-Tenant Configuration
Section titled “Multi-Tenant Configuration”server { listen 443 ssl http2; server_name yourdomain.com *.yourdomain.com;
ssl_certificate /home/t8k/etc/letsencrypt/live/yourdomain.com/fullchain.pem; ssl_certificate_key /home/t8k/etc/letsencrypt/live/yourdomain.com/privkey.pem;
location / { proxy_pass http://127.0.0.1:20000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; }}
Testing and Verification
Section titled “Testing and Verification”DNS Propagation
Section titled “DNS Propagation”Check A records:
dig yourdomain.com Adig @8.8.8.8 yourdomain.com Adig @1.1.1.1 yourdomain.com A
Check wildcard:
dig random.yourdomain.com A
Global propagation check:
SSL Certificate
Section titled “SSL Certificate”Test SSL:
curl -I https://yourdomain.comopenssl s_client -connect yourdomain.com:443 -servername yourdomain.com
SSL validation:
- SSL Labs Test
- Should achieve A+ rating
Multi-Tenant Testing
Section titled “Multi-Tenant Testing”Test subdomains:
curl -I https://test.yourdomain.comcurl -I https://another.yourdomain.com
Tenant registration:
Visit https://yourdomain.com/sandbox/register
Troubleshooting
Section titled “Troubleshooting”DNS Issues
Section titled “DNS Issues”Domain not resolving:
# Check nameserversdig NS yourdomain.com
# Check propagationdig yourdomain.com A +trace
Wildcard not working:
# Verify wildcard record existsdig *.yourdomain.com A
# Test specific subdomaindig test.yourdomain.com A
SSL Certificate Issues
Section titled “SSL Certificate Issues”Certificate not found:
# Check certificate filessudo ls -la /home/t8k/etc/letsencrypt/live/yourdomain.com/
# Re-request certificatesudo -u t8k /home/t8k/certbot_venv/bin/certbot certonly --manual -d yourdomain.com -d *.yourdomain.com
Mixed content warnings:
# Check for HTTP resourcesgrep -r "http://" /home/t8k/src/my-tractstack/src/
nginx Issues
Section titled “nginx Issues”Configuration test:
sudo nginx -t
Check logs:
sudo tail -f /var/log/nginx/error.logsudo tail -f /var/log/nginx/access.log
Restart nginx:
sudo systemctl restart nginx
Performance Optimization
Section titled “Performance Optimization”DNS Performance
Section titled “DNS Performance”Lower TTL for changes:
TTL: 300 (5 minutes) during changesTTL: 3600 (1 hour) for stable setup
Use DNS providers close to users:
- Cloudflare: Global anycast network
- Route 53: AWS global infrastructure
- Google DNS: Google’s global network
CDN Integration
Section titled “CDN Integration”Cloudflare CDN:
- Enable proxy (orange cloud) on DNS records
- Configure caching rules
- Set up page rules for static assets
Custom CDN:
# nginx configuration for CDNlocation ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { expires 1y; add_header Cache-Control "public, immutable"; add_header X-CDN-Cache "MISS";}
Security Considerations
Section titled “Security Considerations”DNS Security
Section titled “DNS Security”DNSSEC (if supported): Enable DNSSEC at your DNS provider for additional security.
DNS over HTTPS: Consider using DoH for enhanced privacy.
Domain Protection
Section titled “Domain Protection”Domain locking: Enable registrar lock to prevent unauthorized transfers.
Privacy protection: Use domain privacy to protect WHOIS information.
Monitoring: Set up monitoring for DNS changes and certificate expiration.
Proper domain and DNS configuration ensures reliable access to your TractStack site. Take time to verify all records are correct before going live.