- Notifications
You must be signed in to change notification settings - Fork625
Routing
Since an automatically generated routing table can only be changed with aservice deployment additional routing commands can be stored manually in theconsul KV store which get appended to the automatically generated routingtable. This allows fine-tuning and fixing of problems without a deployment.
The routing commands are also stored in the KV store.
The routing table is configured with commands in the language specified below.
Blank lines and lines starting with#
or//
are ignored.
Add a route for a servicesvc
for thesrc
(e.g./path
or:port
) to adst
(e.g.URL
orhost:port
).
route add <svc> <src> <dst>[ weight <w>][ tags "<t1>,<t2>,..."][ opts "k1=v1 k2=v2 ..."]
Option | Description |
---|---|
strip=/path | Forward/path/to/file as/to/file |
proto=tcp | Upstream service is TCP,dst must be:port |
proto=https | Upstream service is HTTPS |
tlsskipverify=true | Disable TLS cert validation for HTTPS upstream |
host=name | Set theHost header toname . Ifname == 'dst' then theHost header will be set to the registered upstream host name |
# route traffic for product-svc to 1.2.3.4:8000 and :9000route add product-svc /product http://1.2.3.4:8000route add product-svc /product http://1.2.3.4:9000
Remove one or more routes which match the given criteria.
route del <svc>[ <src>[ <dst>]]route del <svc> tags "<t1>,<t2>,..."route del tags "<t1>,<t2>,..."
# remove all routes for 'product-svc'route del product-svc# remove all routes for 'product-svc' and /pathroute del product-svc /path# remove single routeroute del product-svc /path http://1.2.3.4:8000# remove all routes for 'product-svc' matching a tagroute del product-svc tags "green"# remove all routes matching a tagroute del tags "yesterday"
Directs a certain amount of traffic to instances matching certain criteria.
The weightw
is expressed as follows:
w
is a float > 0 describing a percentage, e.g. 0.5 == 50%w <= 0
: means no fixed weighting. Traffic is evenly distributedw > 0
: route will receive n% of traffic. If sum(w) > 1 then w is normalized.sum(w) >= 1
: only matching services will receive traffic
Note that the total sum of traffic sent to all matching routes isw
%.
The order of commands matters but routes are always ordered from most to leastspecific by prefix length.
route weight <svc> <src> weight <w> tags "<t1>,<t2>,..."route weight <src> weight <w> tags "<t1>,<t2>,..."route weight <svc> <src> weight <w>route weight service host/path weight w tags "tag1,tag2"
# Route 5% of the traffic to product-svc:/path with tags "green"route weight product-svc /path weight .05 tags "green"# Route 5% of the traffic to '/path' to the Go implementation.# Route the rest (95%) to the other implementationroute weight /path weight .05 tags "lang=go"# Route 5% of the traffice to '/path' on the product-svc-goroute weight product-svc-go /path weight .05
The routing table contains first all routes with a host sorted by prefixlength in descending order and then all routes without a host again sorted byprefix length in descending order.
For each incoming request the routing table is searched top to bottom for amatching route. A route matches if eitherhost/path
or - if there was nomatch - just/path
matches.
The matching route determines the target URL depending on the configuredstrategy.rnd
andrr
are available withrnd
being the default.
The auto-generated routing table is
route add service-a www.mp.dev/accounts/ http://host-a:11050/ tags "a,b"route add service-a www.kjca.dev/accounts/ http://host-a:11050/ tags "a,b"route add service-a www.dba.dev/accounts/ http://host-a:11050/ tags "a,b"route add service-b www.mp.dev/auth/ http://host-b:11080/ tags "a,b"route add service-b www.kjca.dev/auth/ http://host-b:11080/ tags "a,b"route add service-b www.dba.dev/auth/ http://host-b:11080/ tags "a,b"
The manual configuration under/fabio/config
is
route del service-b www.dba.dev/auth/route add service-c www.somedomain.com/ http://host-z:12345/
The complete routing table then is
route add service-a www.mp.dev/accounts/ http://host-a:11050/ tags "a,b"route add service-a www.kjca.dev/accounts/ http://host-a:11050/ tags "a,b"route add service-a www.dba.dev/accounts/ http://host-a:11050/ tags "a,b"route add service-b www.mp.dev/auth/ http://host-b:11080/ tags "a,b"route add service-b www.kjca.dev/auth/ http://host-b:11080/ tags "a,b"route add service-c www.somedomain.com/ http://host-z:12345/ tags "a,b"
- Home
- Quickstart
- Installation
- Verifying Releases
- Configuration
- Binding to low ports
- Deployment
- Features
- Access Logging ⭐️
- Certificate Stores
- Compression
- Circonus Support
- DataDog Support
- Docker Support
- Dynamic Reloading
- Graceful Shutdown
- Graphite Support
- HTTP Header
- HTTPS Upstream
- Metrics Support
- Path Stripping
- PROXY Protocol
- Request Debugging
- Request Tracing
- SSE Support
- StatsD Support
- TCP Proxy ⭐️
- TCP+SNI Support
- Traffic Shaping
- Vault Integration
- Websockets
- Web UI
- Performance
- Service Configuration
- Routing
- Debugging
- Contributing
- Why fabio?