Your first route

A route answers one question - is this request for me - and then says what to do with it. This page creates one that proxies an internal service, and checks it before letting anyone near it.

Say the service is an invoicing application, reachable inside your cluster at billing:8080, and you want it served on /billing.

Before you start

Create the route

Open the editor

In the console, go to Infra > Routes and click the round + button at the bottom right of the screen (its tooltip says New route). The editor opens in a drawer, with the sections of a route down the left. Two of them carry a star, which means the route cannot be saved without them: Target and Predicates. The other sections (Identity, Gates, Rate limits, Auth forward, OpenTelemetry...) are optional: leave them for now.

Name it

Type the name in the Name field at the top of the drawer - billing will do. The name is what you will look for in the table, in the traffic curves and in the audit trail.

The route editor on an existing route, Orders API, open on Target: the mode, the upstream and its port, the timeouts

Say what answers: Target

Target decides how the route answers, with its Mode list. Five modes, and only the first one calls a service:

Mode What it does
Proxy fetches from an upstream and hands back what it said
Redirect sends the browser somewhere else (redirect)
Maintenance serves the built-in unavailable page (maintenance)
Respond answers from a template, calling nothing (respond)
Files serves files uploaded on the route (files)

Keep Proxy. In Upstream, keep http in the small list in front of the field and type billing:8080. Plain http is the default on purpose - inside a cluster, TLS usually ends at the gateway and the hop to the service is cleartext. https and h2c are the other two choices; for https, read If your service is in https first.

When the gateway can see your services

Where the gateway can read its runtime - a Docker or Swarm socket, or a Kubernetes namespace from the inside - the services it found are offered in the Upstream field as you focus it, once each: the short name, with the full name a pick stores on a smaller line under it (billing.acme.svc on Kubernetes, stack_billing on Swarm). Its Port sits beside it, a list when the service has several. Free text stays free: an upstream outside the cluster is typed.

The same section holds how long this upstream may take (Connect within, First answer within) and whether to stop calling it when it stops answering. Both inherit from the installation until you say otherwise, so leave them alone for now.

Say which requests: Predicates

Predicates is the is this for me half. Open it, click Add, pick Path and type the pattern /billing/**.

A route may carry several predicates, and they are combined with AND: a path plus a host plus a method is one route that wants all three. The list under Add offers the eleven: Path, Host, Method, Header, Cookie, Query, Remote addr, X forwarded remote addr, Time window, Version and Weight (Predicates).

Three predicates on one route: a path, a method and a header

Strip the prefix

The gateway matched /billing/**, but the invoicing application knows nothing about that prefix - it serves /invoices, not /billing/invoices. Open Incoming, click Add, pick Strip prefix, and leave Segments to strip at 1.

Incoming filters are the request-side transformations: headers, query parameters, path, host. Outgoing does the same on the way back (Filters).

The incoming filters of a route

Say whether people open it: UI

The UI checkbox sits in the left list, above Locales, Color scheme, User button, User info and Custom, which it unlocks.

  • Tick it for pages a person opens in a browser. The invoicing application is one: tick it, and the gateway adds the user button (who is signed in, language, sign out) to its pages.
  • Leave it off for an API called by programs: there is no page to add anything to.

What a UI route gets is described in What the gateway injects.

Say who may pass: Security

Open Security. Its first field, Who may call it, says what a caller must be:

Choice Who passes
Anyone everybody, signed in or not: the service decides for itself
Signed in anyone with an account
In a tenant a signed-in account with an active tenant
In one of these tenants ...and that tenant is one of those you name
With capabilities an account holding one of the administration capabilities you name
Nobody nobody, except the users you name under Exception

Pick Signed in. A caller who does not qualify never reaches the upstream. Roles, named tenants and exceptions are explained in A route's access rule.

The Security section of a route: Who may call it set to Signed in, the roles, and the users always allowed

Save

Click Save, at the bottom right of the drawer. When something is missing, a N to fix button beside it lists what, and each line takes you to the section concerned.

Save applies at once - the routing table is recompiled and, in a cluster, the other nodes are told. There is nothing to restart and no file to reload.

A new route is created with order 0, which puts it at the top of the table. That matters: the first route whose predicates match is the one that answers, so a new route is tried before everything already there.

Check it before your users do

Ask the Routing test

The Routing test button sits in the banner of Infra > Routes. It composes a request that is never sent, and says which route would take it.

  1. Click Routing test.
  2. Keep the method GET and type the path /billing/invoices.
  3. Click Play. With As tenant left on Anonymous, the billing row reads matched, but its security refuses this caller: the rule works.
  4. Pick a tenant in As tenant (or a role in With roles). The row now reads takes this request.

Each route of the table gets one line: takes this request for the one that answers, refused by a predicate for one whose predicates do not match (the detail is in its tooltip), not evaluated for a route below the one that answered whose predicates would have matched too. When no route matches, the dialog says the gateway would answer 404.

The Routing test after Play, for GET /billing/invoices as a member of Acme Logistics: a route for the billing administrators matched but its security refuses this caller, Billing takes the request, the routes below are refused by their path, and the catch-all is not evaluated

Call it for real

From a machine that reaches the gateway:

curl -i http://localhost:8080/billing/invoices

Nobody is signed in on that call, so the rule answers. A program gets a 401:

HTTP/1.1 401 Unauthorized
Www-Authenticate: Session

authentication required

A browser, which asks for text/html, is sent to sign in instead, with the way back:

curl -i -H 'Accept: text/html' http://localhost:8080/billing/invoices
HTTP/1.1 303 See Other
Location: /login?next=%2Fbilling%2Finvoices

Signed in, the service answers. A script presents a personal API token, created on /profile/tokens of the data plane:

curl -i -H 'Authorization: Bearer mk_...' http://localhost:8080/billing/invoices
HTTP/1.1 200 OK
...

The rest of that answer is your service's own. If you get this instead, no route matched the request:

HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8

404 page not found

Check the path predicate and the order of the routes, with the Routing test above. A 502 means a route matched but the gateway could not reach the upstream: check the name and the port you typed in Target.

A signed-in account that the rule turns away (a level it does not meet, a role it does not hold) gets a plain 403 from a script. In a browser, on a UI route, it lands on a page that says which rule refused and what it can do next.

If your service is in https

An upstream in https inside a cluster is usually signed by the cluster's own authority, which the gateway does not know yet: the route answers 502, and the log says certificate signed by unknown authority.

  1. Open Infra > Domains & TLS > Trusted authorities.
  2. Under From the cluster, pick the authority that signs your services (Found in the cluster).
  3. In the route's Target, call the service by its full name, billing.acme.svc, not the bare billing.

An authority constrained to cluster names never certifies the bare billing. The editor flags an https upstream left on a short name, with a button that writes the full name.

Next