0

I have a custom header test: someothervalues;host:https://test-service:443
If the value of the test header contains the test word I want to find out a way to route the request to https://test-service:443 in my istio Virtual Service. I know that I can use a regex to check if the value contains the test word. But I do not know how can I store the regex result of the capture blocks in order to use it in destination block.

The desired template and results should be looked like the following:

yaml template

- match:
    - headers:
        test-host:
          regex: .*(^|;)(host:http[s]?:\/\/)(.*test.*):([0-9]*)[;]?.*
  name: to-test-host
  route:
    - destination:
        host: {{capture group 3 of the above regex }}
        port:
          number: {{capture group 4 of the above regex }}

results

- match:
    - headers:
        test-host:
          regex: .*(^|;)(host:http[s]?:\/\/)(.*test.*):([0-9]*)[;]?.*
  name: to-test-host
  route:
    - destination:
        host: test-service # this is group 3 of the above regex
        port:
          number: 443 # this is group 4 of the above regex
SteveGr2015
  • 463
  • 2
  • 7
  • 15

0 Answers0