Multiple paths access a backend by traefik ingress

7/10/2019

I want to use traefik ingress to achieve the following functions just like nginx:

nginx config:

location she/admin/art/ {
    proxy_pass         http://172.18.214.174:801/admin/;
}
location he/admin/art/ {
    proxy_pass         http://172.18.214.174:801/admin/;
}
location my/admin/art/ {
    proxy_pass         http://172.18.214.174:801/admin/;
}

If I want to achieve this effect in the traefik ingress

I need to use annotations:

traefik.ingress.kubernetes.io/redirect-regex: ^http://www.hx.com/she/admin/art/(.*)
traefik.ingress.kubernetes.io/redirect-replacement: http://www.hx.com/admin/$1

Unfortunately, if I do this, I need to create three ingress just like a silly monkey

-- imapccat
kubernetes
traefik-ingress

1 Answer

7/12/2019

If I understand you correctly:

  1. You can try to use path matching.

  2. You can also try to use rewrite annotation.

  3. If those would not help than you have to setup 3 different Ingress as it will not be a problem for one host.

Please let me know if that helped.

-- OhHiMark
Source: StackOverflow