How to use rewrite in traefik

8/12/2019

I am using abc.com/foo and it is working fine, but whatever url like abc.com/foo/account-login I need to redirect to abc.com/account-login and it is not working. Please let me know how can I set rewrite or any other annotatios in traefik.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    traefik.frontend.rule.type: PathPrefixStrip
    kubernetes.io/ingress.class: traefik
  name: dev-ingress
  namespace: dev
spec:
  rules:
  - host: abc.com
    http:
      paths:
      - backend:
          serviceName: dev-service
          servicePort: http
        path: /foo
status:
  loadBalancer: {}
-- sumit salunke
kubernetes
kubernetes-ingress
traefik
traefik-ingress

2 Answers

8/12/2019
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: traefik
    traefik.ingress.kubernetes.io/rewrite-target: /account-login
  name: dev-ingress
  namespace: dev
spec:
  rules:
  - host: abc.com
    http:
      paths:
      - backend:
          serviceName: dev-service
          servicePort: http
        path: /foo
status:
  loadBalancer: {}
-- Harsh Manvar
Source: StackOverflow

8/16/2019

It depends on your back-and configuration but probably you can try:

remove traefik.frontend.rule.type: PathPrefixStrip" and set path: /

Please let me know if its helps

-- Hanx
Source: StackOverflow