- Advanced configuration topics
- Upgrading Ambassador
- Statistics and Monitoring
- Need Help?
Ambassador can route to target services based on HTTP headers with the
regex_headers annotations. Multiple mappings with different annotations can be applied to construct more complex routing rules.
headers attribute is a dictionary of
value pairs. Ambassador will only allow requests that match the specified
value pairs to reach the target service.
You can also set the
value of a header to
true to test for the existence of a header.
A basic example
--- apiVersion: ambassador/v1 kind: Mapping name: qotm_mapping prefix: /qotm/ headers: x-qotm-mode: canary x-random-header: datawire service: qotm
will allow requests to
/qotm/ to succeed only if the
x-qotm-mode header has the value
canary and the
x-random-header has the value
A conditional example
--- apiVersion: ambassador/v1 kind: Mapping name: qotm_mode_mapping prefix: /qotm/ headers: x-qotm-mode: true service: qotm-mode --- apiVersion: ambassador/v1 kind: Mapping name: qotm_regular_mapping prefix: /qotm/ service: qotm-regular
will send requests that contain the
x-qotm-mode header to the
qotm-mode target, while routing all other requests to the
The following mapping will route mobile requests from Android and iPhones to a mobile service:
name: mobile-ui annotations: getambassador.io/config: | --- apiVersion: ambassador/v1 kind: Mapping name: mobile_ui_mapping regex_headers: user-agent: "^(?=.*\\bAndroid\\b)(?=.*\\b(m|M)obile\\b).*|(?=.*\\biPhone\\b)(?=.*\\b(m|M)obile\\b).*$" prefix: / service: mobile-ui