-
Notifications
You must be signed in to change notification settings - Fork 616
Routing
Since an automatically generated routing table can only be changed with a service deployment additional routing commands can be stored manually in the consul KV store which get appended to the automatically generated routing table. 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 the following commands:
Add route for service svc
from src
to dst
with optional weight
, tags
and options
.
Valid options are:
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 the Host header to name . If name == 'dst' then the Host header will be set to the registered upstream host name |
Remove route matching svc
, src
and/or dst
.
Remove all routes of service matching svc
and tags
.
Remove all routes matching tags
.
Route w
% of traffic to all services matching svc
, src
and tags
.
Route w
% of traffic to all services matching src
and tags
.
Route w
% of traffic to all services matching svc
and src
.
Route w
% of traffic to all services matching service
, host/path
and tags
.
-
w
is a float > 0 describing a percentage, e.g. 0.5 == 50% -
w <= 0
: means no fixed weighting. Traffic is evenly distributed -
w > 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 is w
%.
The order of commands matters but routes are always ordered from most to least specific by prefix length.
The routing table contains first all routes with a host sorted by prefix length in descending order and then all routes without a host again sorted by prefix length in descending order.
For each incoming request the routing table is searched top to bottom for a
matching route. A route matches if either host/path
or - if there was no
match - just /path
matches.
The matching route determines the target URL depending on the configured
strategy. rnd
and rr
are available with rnd
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?