<p>I have a web app and its corresponding backend service deployed in k8s. They are exposed as follows through services:</p>
<ol>
<li>Web App -&gt; <a href="http://1.2.3.4:8080/webapp/login" rel="nofollow noreferrer">http://1.2.3.4:8080/webapp/login</a></li>
<li>Backend -&gt; <a href="http://5.6.7.8:8081/backend-service/login" rel="nofollow noreferrer">http://5.6.7.8:8081/backend-service/login</a></li>
</ol>
<p>I have configured ingress resource for these service but it turns out NGINX ingress controller is skipping the context root part while rewriting the url which is making my service unavailable when I am deploying it through ingress. Below is my ingress resource:</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  namespace: default
  name: gateway-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/use-regex: true
spec:
  rules:
    - http:
        paths:
          - path: /webapp/*
            backend:
              serviceName: webapp-service
              servicePort: 8080
          - path: /backend-service/*
            backend:
              serviceName: backend-service
              servicePort: 8081


**Output of : kubectl describe ingress gateway-ingress**

Name:             gateway-ingress
Namespace:        default
Address:          test.elb.us-east-2.amazonaws.com
Default backend:  default-http-backend:80 (&lt;none&gt;)
Rules:
  Host  Path  Backends
  ----  ----  --------
  *     
        /webapp/*                 webapp-service:8080 (1.2.3.4:8080)
        /backend-service/*        backend-service:8081 (5.6.7.8:8081)
</code></pre>
<p>So when I am accessing my application using <strong><a href="http://test.elb.us-east-2.amazonaws.com/webapp/login" rel="nofollow noreferrer">http://test.elb.us-east-2.amazonaws.com/webapp/login</a></strong> I am getting 404 not found. How can i configure ingress resource correctly?</p>

Prerak Tiwari
<p>Application context removal is caused by the <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#rewrite" rel="nofollow noreferrer">rewrite-target</a> annotation. Just remove it if it's not needed.</p>
