Skip to content
Frank Schröder edited this page Oct 18, 2017 · 11 revisions

This is how you use fabio in your setup:

  1. Register your service in consul.

    Make sure that each instance registers with a unique ServiceID and a service name without spaces.

  2. Register a health check in consul as described here.

    Make sure the health check is passing since fabio will only watch services which have a passing health check.

  3. Register one urlprefix- tag per host/path prefix it serves, e.g.:

# HTTP/S examples
urlprefix-/css                                     # path route
urlprefix-i.com/static                             # host specific path route
urlprefix-mysite.com/                              # host specific catch all route
urlprefix-/foo/bar strip=/foo                      # path stripping (forward '/bar' to upstream)
urlprefix-/foo/bar proto=https                     # HTTPS upstream
urlprefix-/foo/bar proto=https tlsskipverify=true  # HTTPS upstream and self-signed cert

# TCP examples
urlprefix-:3306 proto=tcp                          # route external port 3306

Make sure the prefix contains at least one slash (/).

See the full list of options in the Documentation.

  1. Start fabio without a config file (assuming a running consul agent on localhost:8500) Watch the log output how fabio picks up the route to your service. Try starting/stopping your service to see how the routing table changes instantly.

    Check Docker Support to see how to run fabio inside a docker container.

  2. Send all your HTTP traffic to fabio on port 9999

  3. Done

To start a sample server to test the routing run the demo/server like this:

./server -addr 127.0.0.1:5000 -name svc-a -prefix /foo

and access the server direct and via fabio

curl 127.0.0.1:5000/foo   # direct
curl 127.0.0.1:9999/foo   # via fabio

fabio can terminate TLS connections and handle client certificate authentication. Check the documentation on Certificate Stores for details.

Check the Debugging section to test how fabio routes requests.

Check the Features page for a full list of features.

Check out fabio.properties for a full list of config options.

Last but not least have fun :)

Frank