Traefik rewrite URL not working

Hi everyone!

I have the following ingress config. I’m using a traefik ingress controller.
What I want to do is to redirect all the requests from routing.mydomain.ro/car-fastest to routing.mydomain.ro/ because my pod is listening for requests coming from / .

As you can see in my config, I’m using traefik.ingress.kubernetes.io/rewrite-target: / but this doesn’t seem to work, to rewrite my URL. because my response from my pod is {"message":"URL string malformed close to position 4: \"car-fa\"","code":"InvalidUrl"} because is expecting a request coming from / .

If anyone has any suggestions, they are welcome.

Thanks!

kind: Ingress
metadata:
  annotations:
    field.cattle.io/publicEndpoints: '[{"addresses":["192.168.47.63"],"port":443,"protocol":"HTTPS","serviceName":"osrm-namespace:osrm-backend-car-fastest","ingressName":"osrm-namespace:osrm-car-fastest","hostname":"routing.mydomain.ro","path":"/car-fastest","allNodes":false}]'
    traefik.ingress.kubernetes.io/rewrite-target: /
  creationTimestamp: "2021-12-22T12:10:24Z"
  generation: 1
  managedFields:
  - apiVersion: networking.k8s.io/v1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          .: {}
          f:traefik.ingress.kubernetes.io/rewrite-target: {}
      f:spec:
        f:rules: {}
        f:tls: {}
    manager: agent
    operation: Update
    time: "2021-12-22T12:10:24Z"
  - apiVersion: extensions/v1beta1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          f:field.cattle.io/publicEndpoints: {}
    manager: rancher
    operation: Update
    time: "2021-12-22T12:10:24Z"
  - apiVersion: extensions/v1beta1
    fieldsType: FieldsV1
    fieldsV1:
      f:status:
        f:loadBalancer:
          f:ingress: {}
    manager: traefik
    operation: Update
    time: "2021-12-22T12:10:24Z"
  name: osrm-car-fastest
  namespace: osrm-namespace
  resourceVersion: "6180987"
  uid: a08ab4b4-4229-4b16-a5b7-fd63197588dc
spec:
  rules:
  - host: routing.mydomain.ro
    http:
      paths:
      - backend:
          service:
            name: osrm-backend-car-fastest
            port:
              number: 5000
        path: /car-fastest
        pathType: Prefix
  tls:
  - hosts:
    - routing.mydomain.ro
    secretName: mydomain-wildcard
status:
  loadBalancer:
    ingress:
    - ip: 192.168.47.63
1 Like