<p>I'm deploying a simple app in Kubernetes (on AKS) which is sat behind an Ingress using Nginx, deployed using the Nginx helm chart. I have a problem that for some reason Nginx doesn't seem to be passing on the full URL to the backend service. </p>

<p>For example, my Ingress is setup with the URL of <a href="http://app.client.com" rel="nofollow noreferrer">http://app.client.com</a> and a path of /app1g going <a href="http://app.client.com/app1" rel="nofollow noreferrer">http://app.client.com/app1</a> works fine. However if I try to go to <a href="http://app.client.com/app1/service1" rel="nofollow noreferrer">http://app.client.com/app1/service1</a> I just end up at <a href="http://app.client.com/app1" rel="nofollow noreferrer">http://app.client.com/app1</a>, it seems to be stripping everything after the path.</p>

<p>My Ingress looks  like this:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
  creationTimestamp: "2019-04-03T12:44:22Z"
  generation: 1
  labels:
    chart: app-1.1
    component: app
    hostName: app.client.com
    release: app
  name: app-ingress
  namespace: default
  resourceVersion: "1789269"
  selfLink: /apis/extensions/v1beta1/namespaces/default/ingresses/app-ingress
  uid: 34bb1a1d-560e-11e9-bd46-9a03420914b9
spec:
  rules:
  - host: app.client.com
    http:
      paths:
      - backend:
          serviceName: app-service
          servicePort: 8080
        path: /app1
  tls:
  - hosts:
    - app.client.com
    secretName: app-prod
status:
  loadBalancer:
    ingress:
    - {}
</code></pre>

<p>If I port forward to the service and hit that directly it works.</p>

Sam Cogan
<p>So I found the answer to this. It seems that as of Nginx v0.22.0 you are required to use capture groups to capture any substrings in the request URI. Prior to 0.22.0 using just  <code>nginx.ingress.kubernetes.io/rewrite-target: /</code> worked for any substring. Now it does not. I needed to ammend my ingress to use this:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$1
  creationTimestamp: "2019-04-03T12:44:22Z"
  generation: 1
  labels:
    chart: app-1.1
    component: app
    hostName: app.client.com
    release: app
  name: app-ingress
  namespace: default
  resourceVersion: "1789269"
  selfLink: /apis/extensions/v1beta1/namespaces/default/ingresses/app-ingress
  uid: 34bb1a1d-560e-11e9-bd46-9a03420914b9
spec:
  rules:
  - host: app.client.com
    http:
      paths:
      - backend:
          serviceName: app-service
          servicePort: 8080
        path: /app1/?(.*)
  tls:
  - hosts:
    - app.client.com
    secretName: app-prod
status:
  loadBalancer:
    ingress:
    - {}
</code></pre>
