How to rewrite target to correct path in haproxy-ingress? How to rewrite target to correct path in haproxy-ingress? kubernetes kubernetes

How to rewrite target to correct path in haproxy-ingress?


for HAProxy:

you have to use haproxy annotation:

apiVersion: networking.k8s.io/v1beta1kind: Ingressmetadata:  name: web-ingress  namespace: default  annotations:    # replace all paths with /    haproxy.org/path-rewrite: "/"    # remove the prefix /foo... "/bar?q=1" into "/foo/bar?q=1"    haproxy.org/path-rewrite: (.*) /foo\1    # add the suffix /foo ... "/bar?q=1" into "/bar/foo?q=1"    haproxy.org/path-rewrite: ([^?]*)(\?(.*))? \1/foo\2    # strip /foo ... "/foo/bar?q=1" into "/bar?q=1"    haproxy.org/path-rewrite: /foo/(.*) /\1spec:  # ingress specification...

Ref: => https://www.haproxy.com/documentation/kubernetes/1.4.5/configuration/ingress/