Home > database >  Is there a way to remove double slash using regex in ambassador emissary ingress?
Is there a way to remove double slash using regex in ambassador emissary ingress?

Time:03-01

I have deployed ambassador edge stack and I am using hosts and mapping resources to route my traffic. I want to implement the mapping in such a way that if there is any double slash in the path, using regex(or any other available way) remove one slash from it. For example, if client request https://a.test.com//testapi I want it to be https://a.test.com/testapi.

I search through the ambassador documents but I am unable to find anything that can be of help.

Thank You

CodePudding user response:

There is the Module Resource for emissary ingress.

If present, the Module defines system-wide configuration. This module can be applied to any Kubernetes service (the ambassador service itself is a common choice). You may very well not need this Module. To apply the Module to an Ambassador Service, it MUST be named ambassador, otherwise it will be ignored. To create multiple ambassador Modules in the same namespace, they should be put in the annotations of each separate Ambassador Service.

You should add this to the module's yaml file:

spec:
...
  config:
...
    merge_slashes: true

If true, Emissary-ingress will merge adjacent slashes for the purpose of route matching and request filtering. For example, a request for //foo///bar will be matched to a Mapping with prefix /foo/bar.

  • Related