Ambassador Edge Stack supports several different methods for managing the HTTP
A mapping that specifies the
host attribute will take effect only if the HTTP
Host header matches the value in the
host attribute. If
host value is taken to be a regular expression. Otherwise, an exact string match is required.
You may have multiple mappings listing the same resource but different
host attributes to effect
Host-based routing. An example:
---apiVersion: getambassador.io/v2kind: Mappingmetadata:name: quote-backendspec:prefix: /backend/service: quote1---apiVersion: getambassador.io/v2kind: Mappingmetadata:name: quote-backend-2spec:prefix: /backend/host: quote.datawire.ioservice: quote2---apiVersion: getambassador.io/v2kind: Mappingmetadata:name: quote-backend-3spec:prefix: /backend/host: "^quote[2-9]\\.datawire\\.io$"host_regex: trueservice: quote3
will map requests for
quote2service if the
quote3service if the
^quote[2-9]\\.datawire\\.io$; and to
Note that enclosing regular expressions in quotes can be important to prevent backslashes from being doubled.
By default, the
Host header is not altered when talking to the service -- whatever
Host header the client gave to Ambassador Edge Stack will be presented to the service. For many microservices, this will be fine, but if you use Ambassador Edge Stack to route to services that use the
Host header for routing, it's likely to fail (legacy monoliths are particularly susceptible to this, as well as external services). You can use
host_rewrite to force the
Host header to whatever value that such target services need.
An example: the default Ambassador Edge Stack configuration includes the following mapping for
---apiVersion: getambassador.io/v2kind: Mappingmetadata:name: httpbinspec:prefix: /httpbin/service: httpbin.org:80host_rewrite: httpbin.org
As it happens,
httpbin.org is virtually hosted, and it simply will not function without a
Host header of
httpbin.org, which means that the
host_rewrite attribute is necessary here.
hostattribute becomes a
headermatch on the
methodattribute becomes a
headermatch on the
You will see these headers in the diagnostic service if you use the