<p>I have the ingress setup for Kubernetes as the following</p>
<pre><code>    apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: dev-ingress
  #namespace: dev
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
    ingress.gcp.kubernetes.io/pre-shared-cert: &quot;self-signed&quot;
    kubernetes.io/ingress.class: &quot;nginx&quot;
    kubernetes.io/ingress.allow-http: &quot;true&quot;
spec:
  rules:
  - host: my.host.com
    http:
      paths:
      - backend:
          serviceName: webui-svc
          servicePort: 80
        path: /webui(/|$)(.*)
</code></pre>
<p>I am running an Angular app deployment under the webui-svc. The angular app is containerized using docker and I have included a Nginx configuration in the docker container like the following</p>
<pre><code>    # Expires map
    map $sent_http_content_type $expires {
        default                    off;
        text/html                  epoch;
        text/css                   max;
        application/json           max;
        application/javascript     max;
        ~image/                    max;
    }
    
    server {
      listen 80;
      location / {
          root /usr/share/nginx/html;
          index index.html index.htm;
          try_files $uri $uri/ /index.html =404;
        }
      expires $expires;
      gzip  on;

}
</code></pre>
<p>When i am requesting for <a href="http://my.host.com/webui/" rel="nofollow noreferrer">http://my.host.com/webui/</a> the internal calls are getting redirected without the webui prefixed to it for e.g</p>
<p>When i request for <a href="http://my.host.com/webui/" rel="nofollow noreferrer">http://my.host.com/webui/</a> there are several calls made to get the main.js, vendor.js etc these all the requested via <a href="http://my.host.com/runtime.js" rel="nofollow noreferrer">http://my.host.com/runtime.js</a>  so it fails, it would succeed if it would get redirected like <a href="http://my.host.com/webui/runtime.js" rel="nofollow noreferrer">http://my.host.com/webui/runtime.js</a></p>
<p>Is there a configuration in the angular application or the ingress that I am missing. Any help is very much appreciated, Thanks in advance</p>

Saumadip Mazumder
<p>Your rewrite target is stripping off the <code>/webui/</code>.  Consider your path:</p>
<p><code>path: /webui(/|$)(.*)</code></p>
<p>Now check the <code>rewrite-target</code>:</p>
<p><code>nginx.ingress.kubernetes.io/rewrite-target: /$2</code>.</p>
<p>If you remove this annotation (and you can remove the <code>use-regex</code> annotation since it's now not needed), it will pass the <code>/webui/</code> path onto your backend.</p>
