Endpoints

When a request is received, it is matched with list of endpoint definitions to figure out which endpoint should handle the request. The matching is done based on the host header and the path specified in the request.

Endpoint definitions can contain wildcards in both the host and the path section. This article explains the way the matching logic works in detail.

Matching logic

The endpoints are matched according to the following priorities:

  1. Length of the host header (longer is a better match).
  2. Number of wildcards in the host header (fewer is a better match).
  3. Host header sorted alphanumerically (for consistency).
  4. Length of the path (longer is a better match).
  5. Number of wildcards in the path (fewer is a better match).
  6. Path sorted alphanumerically (for consistency).

Examples

In this example there are four endpoints defined, sorted by the aforementioned priorities:

Endpoint name Host Path
A bar.example.com /*
B *.example.com /*/users/*
C example.com /foo/*
D example.com /*

The following table contains a list of client requests and their endpoint lookup result.

Client request (host path) Lookup result
example.com / Endpoint D
example.com /bar Endpoint D
example.com /foo Endpoint D
example.com /foo/ Endpoint C
example.com /foo/users Endpoint C
example.com /foo/users/42 Endpoint C
bar.example.com /foo/users Endpoint A
bar.example.com /foo/users/42 Endpoint A
zoo.example.com /foo/users/42 Endpoint B

®Varnish Software, Wallingatan 12, 111 60 Stockholm, Organization nr. 556805-6203