Consul Catalog Provider
A Story of Tags, Services & Instances Attach tags to your Consul services and let Traefik automatically discover and route traffic. The Consul Catalog provider watches service registrations in HashiCorp Consul and dynamically updates routing configuration.Quick Start
1
Enable Consul Catalog Provider
2
Register Service with Tags
3
Access Your Service
Traefik automatically detects the service and creates routes!
How It Works
The Consul Catalog provider:- Polls Consul at regular intervals (or uses watch mode)
- Discovers services with tags matching the configured prefix
- Extracts routing configuration from service tags
- Creates routes dynamically
- Updates on changes when services are added/removed
Service Registration Examples
Basic HTTP Service
Service with Middleware
Multiple Routers per Service
Provider Configuration
endpoint
Consul server connection settings.address
Default:127.0.0.1:8500
scheme
Optional, Default:""
URI scheme (http or https):
datacenter
Optional, Default: Agent’s datacentertoken
Optional, Default:""
Consul ACL token:
httpAuth
HTTP Basic Authentication:tls
TLS configuration for secure connection:prefix
Default:traefik
Tag prefix for Traefik configuration:
refreshInterval
Default:15s
Polling interval:
Ignored when
watch: true is enabled.watch
Optional, Default: false Use Consul watches for real-time updates:exposedByDefault
Default:true
Expose all services by default:
defaultRule
Default:Host(`{{ normalize .Name }}`)
Default routing rule template:
constraints
Optional, Default:""
Filter services by tags:
Consistency Mode
Control Consul read consistency:requireConsistent
Default:false
Force fully consistent reads:
stale
Default:false
Allow stale reads (faster, scalable):
cache
Default:false
Use local agent caching:
Consul Connect
connectAware
Default:false
Enable Consul Connect support:
connectByDefault
Default:false
Treat all services as Connect-capable:
namespaces (Enterprise)
Optional, Default:""
Watch specific Consul Enterprise namespaces:
Requires Consul Enterprise with namespace support.
strictChecks
Default:["passing", "warning"]
Health check statuses allowed to receive traffic:
Complete Example
Advanced Patterns
Canary Deployments
Multi-Datacenter Setup
Service Mesh with Consul Connect
Tag Syntax
All Traefik labels work as Consul tags, replacing. with the prefix:
- Docker Labels
Troubleshooting
Services Not Discovered
1
Check Consul Connection
2
Verify Service Tags
3
Check exposedByDefault
If
false, ensure service has traefik.enable=true tag.4
Review Constraints
Verify service tags match configured constraints.
Health Checks Failing
ACL Errors
Ensure token has proper permissions:Best Practices
1
Use Health Checks
Always configure Consul health checks for services.
2
Enable Watch Mode
Use
watch: true for real-time updates instead of polling.3
Set Proper Consistency
Use
stale: true for better performance in large deployments.4
Tag Consistently
Develop a tagging strategy (environment, version, team, etc.).
5
Secure Communication
Use TLS and ACL tokens for Consul connections.
Next Steps
Routing Overview
Learn about routing configuration
Consul Documentation
Official HashiCorp Consul documentation