<p>I'm using the Azure AKS addon for HTTP application routing as described <a href="https://learn.microsoft.com/en-us/azure/aks/http-application-routing" rel="noreferrer">here</a>. I deployed it using Terraform and it generally works:</p>
<pre><code>resource &quot;kubernetes_ingress&quot; &quot;ingress&quot; {
  metadata {
    name      = &quot;nurse-ingress&quot;
    namespace = kubernetes_namespace.nurse.metadata[0].name
    annotations = {
      &quot;kubernetes.io/ingress.class&quot; = &quot;addon-http-application-routing&quot;
      &quot;nginx.ingress.kubernetes.io/rewrite-target&quot; = &quot;/$1&quot;
    }
  }

  wait_for_load_balancer = true

  spec {
    backend {
      service_name = &quot;nurse-service&quot;
      service_port = 80
    }

    rule {
      host = &quot;nurseapp.${azurerm_kubernetes_cluster.main.addon_profile[0].http_application_routing[0].http_application_routing_zone_name}&quot;
      http {
        path {
          backend {
            service_name = kubernetes_service.app.metadata[0].name
            service_port = 80
          }

          path = &quot;/app/(.*)&quot;
        }

        path {
          backend {
            service_name = kubernetes_service.nurse.metadata[0].name
            service_port = 80
          }

          path = &quot;/nurse/(.*)&quot;
        }
      }
    }
  }
}
</code></pre>
<p>However, it only works on the default backend (i.e. path=/). When I call the URL on /nurse or /app it does not work since the rewrite-target <code>/$1</code> does not seem to be taken into account. I will just get a 404 - since the nurse-service itself does expect calls on /foo and not on /nurse/foo</p>
<p>Should this be possible to configure to begin with and if so, any idea where my mistake is?</p>
<p><a href="https://i.stack.imgur.com/PPtzX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PPtzX.png" alt="enter image description here" /></a></p>

silent
<p>The following will rewrite the path so that requests for <code>/sample/suffix</code> will be rewritten as <code>/suffix</code>:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: sample-ingress
  annotations:
    kubernetes.io/ingress.class: addon-http-application-routing
    nginx.ingress.kubernetes.io/rewrite-target: $2
spec:
  rules:
  - host: sample.YOUR-ID.westeurope.aksapp.io
    http:
      paths:
      - path: /sample/
        pathType: Prefix
        backend:
          service:
            name: sample
            port:
              number: 80
</code></pre>
