How can I configure nginx.ingress.kubernetes.io/rewrite-target
and spec.rules.http.paths.path
to satisfy the following URI patterns?
/aa/bb-aa/coolapp
/aa/bb-aa/coolapp/cc
Legend:
- a = Any letter between a-z. Lowercase. Exactly 2 letters - no more, no less.
- b = Any letter between a-z. Lowercase. Exactly 2 letters - no more, no less.
- c = any valid URI character. Lowercase. Of variable length - think slug.
Example URI:s that should match the above pattern:
/us/en-us/coolapp
/us/en-us/coolapp/faq
/us/en-us/coolapp/privacy-policy
Attention
Starting in Version 0.22.0, ingress definitions using the annotation nginx.ingress.kubernetes.io/rewrite-target
are not backwards compatible with previous versions. In Version 0.22.0 and beyond, any substrings within the request URI that need to be passed to the rewritten path must explicitly be defined in a capture group.
Note
Captured groups are saved in numbered placeholders, chronologically, in the form $1
, $2
... $n
. These placeholders can be used as parameters in the rewrite-target annotation.
References: