<p>I have an ingress controller and ingress resource running with all /devops mapped to devopsservice in the backend. When I try to hit "<a href="http://hostname/devops" rel="noreferrer">http://hostname/devops</a>" things work and I get a page (although without CSS and styles) with a set of hyperlinks for e.g one of them is "logs".</p>

<p>When I click on the "logs" hyperlink, it is redirecting me to <a href="http://hostname/logs" rel="noreferrer">http://hostname/logs</a> whereas I need it to be <a href="http://hostname/devops/logs" rel="noreferrer">http://hostname/devops/logs</a>.</p>

<p>Any idea what I can do?</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
 name: my-ingress
 namespace: ingress-nginx
 annotations:
   kubernetes.io/ingress.class: nginx
   nginx.ingress.kubernetes.io/rewrite-target: /
   nginx.ingress.kubernetes.io/add-base-url : "true"
spec:
 rules:
 - host: master1.dev.local
   http:
     paths:
     - backend:
         serviceName: devops1
         servicePort: 10311
       path: /devops
</code></pre>

user1722908
<p>Looks like your ingress is not serving anything <code>/devops/*</code>. Try adding another path <code>/devops/*</code> with the same backend. Basically this:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
 name: my-ingress
 namespace: ingress-nginx
 annotations:
   kubernetes.io/ingress.class: nginx
   nginx.ingress.kubernetes.io/rewrite-target: /
   nginx.ingress.kubernetes.io/add-base-url : "true"
spec:
 rules:
 - host: master1.dev.local
   http:
     paths:
     - backend:
         serviceName: devops1
         servicePort: 10311
       path: /devops/*
     - backend:
         serviceName: devops1
         servicePort: 10311
       path: /devops
</code></pre>

<p>Update: the above has been <a href="https://github.com/kubernetes/ingress-nginx/pull/3174" rel="noreferrer">deprecated</a> in favor of something like this:</p>

<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
  name: rewrite
  namespace: default
spec:
  rules:
  - host: master1.dev.local
    http:
      paths:
      - backend:
          serviceName: devops1
          servicePort: 10311
        path: /devops(/|$)(.*)
</code></pre>
