Domains
This comprehensive guide explains how to configure domain routing for your Docker Compose applications using Hawiyat's infrastructure. You'll learn advanced domain configuration techniques, SSL/TLS setup, and best practices for production deployments.
Overview
When configuring domains in a Docker Compose environment, you'll need to understand several key components:
Core Components
- Hawiyat Network: A managed overlay network that enables service discovery and load balancing
- Traefik Integration: An advanced reverse proxy that handles routing, SSL termination, and load balancing
- DNS Configuration: Setting up proper DNS records for your domains
- SSL/TLS Certificates: Automatic certificate generation and renewal
Key Benefits
- Automatic SSL certificate management
- Zero-downtime deployments
- Built-in load balancing
- Service discovery
- Health checking
- Metrics and monitoring
Prerequisites
- A Hawiyat account with appropriate permissions
- Basic understanding of DNS and networking concepts
- Familiarity with Docker Compose
- One or more registered domains
Implementation Steps
- Add your services to the
hawiyat-network
for proper service discovery - Configure Traefik labels for intelligent routing
- Set up SSL/TLS certificates
- Configure DNS records
Example Scenario
Let's consider an application with three components: a frontend, a backend, and a database. We'll start with a basic Docker Compose file and then enhance it with domain configuration.
Step 1: Add the Network
First, we'll add the hawiyat-network to our services:
Step 2: Configuring Traefik Labels
Now, let's add Traefik labels to route domains to our services. We'll focus on the frontend and backend services:
Understanding Traefik Configuration
Label Architecture
Traefik uses a label-based configuration system that provides fine-grained control over routing, middleware, and load balancing. Here's a detailed breakdown of each label:
-
Service Enablement
- Activates Traefik routing for the service
- Required for all services that need routing
- Can be disabled for internal services
-
Domain Configuration
- Defines the domain routing rule
- Supports multiple domains using OR:
Host(
domain1.com) || Host(
domain2.com)
- Allows path-based routing:
Host(
api.domain.com) && PathPrefix(
/v1)
-
Entrypoint Configuration
- Defines the network entry point
- Common values:
web
(HTTP),websecure
(HTTPS) - Can specify multiple entrypoints for different protocols
-
Load Balancer Configuration
- Specifies the internal service port
- Supports sticky sessions and health checks
- Can configure load balancing algorithms
Advanced Label Options
-
Middleware Configuration
- Apply transformations to requests/responses
- Examples: authentication, rate limiting, headers
-
TLS Configuration
- Enables automatic SSL/TLS certificate management
- Supports multiple certificate resolvers
Important: Replace <UNIQUE-RULE>
with a descriptive, unique identifier for each service (e.g., frontend-app
, backend-api
, admin-dashboard
). Use consistent naming across related labels.
Production Best Practices
Security Considerations
-
Port Management
- Use
expose
instead ofports
for internal service communication - Avoid exposing unnecessary ports to the host
- Implement proper network segmentation
- Use
-
SSL/TLS Configuration
- Always use HTTPS in production
- Enable automatic certificate renewal
- Configure proper SSL ciphers
-
Network Security
- Use internal networks for service-to-service communication
- Implement proper access controls
- Enable rate limiting for public endpoints
DNS Configuration
-
Record Types
- Create
A
records pointing to Hawiyat's infrastructure - Use
CNAME
records for subdomains - Consider
CAA
records for certificate authority restrictions
- Create
-
DNS Propagation
- Allow time for DNS changes to propagate (usually 0-48 hours)
- Use DNS checking tools to verify propagation
- Configure appropriate TTL values
-
Monitoring
- Set up DNS monitoring
- Configure alerts for DNS issues
- Regular DNS health checks
Deployment Strategies
-
Zero-Downtime Deployment
- Use rolling updates
- Implement health checks
- Configure proper update delays
-
Monitoring and Logging
- Enable Traefik access logs
- Configure application logging
- Set up metrics collection
-
Scaling Considerations
- Configure proper resource limits
- Implement load balancing
- Use Docker Compose v3+ features
Advanced Configuration and Troubleshooting
SSL/TLS Certificate Management
-
Automatic Certificate Generation
- Let's Encrypt integration
- Certificate renewal automation
- Multiple domain support
-
Manual Certificate Configuration
- Custom certificate support
- Certificate chain configuration
- Private key management
Common Issues and Solutions
-
Certificate Problems
- Check DNS configuration
- Verify domain ownership
- Review Traefik logs
-
Routing Issues
- Validate label configuration
- Check network connectivity
- Verify service health
-
Performance Optimization
- Configure caching
- Implement compression
- Enable HTTP/2
Additional Resources
For more detailed information and advanced configurations, refer to:
-
- Deep dive into certificate types
- Advanced SSL configuration
- Security best practices
-
- Complete domain configuration
- Advanced routing scenarios
- Production deployment guides
-
- Real-world configurations
- Best practices examples
- Common patterns
Community and Support
- Join our Discord server for real-time support
- Check our GitHub repository for updates
- Subscribe to our newsletter for latest features and best practices