<p>I have two services running:</p>

<pre><code>$kubectl get services
NAME         TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
kubernetes   ClusterIP   10.96.0.1      &lt;none&gt;        443/TCP          49m
shiny        NodePort    10.110.49.57   &lt;none&gt;        3838:30240/TCP   34m
web          NodePort    10.98.56.71    &lt;none&gt;        80:31758/TCP     39m
</code></pre>

<p>And the following ingress:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: / 
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
  - http:
      paths:
      - path: /*
        backend:
          serviceName: web
          servicePort: 80
      - path: /shiny/*
        backend:
          serviceName: shiny
          servicePort: 3838
</code></pre>

<p>I get the behavior I want from <code>shiny</code> if I access it directly through <code>minikube service shiny</code>:</p>

<p><a href="https://i.stack.imgur.com/PLq8z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R6vxg.jpg" /></a></p>

<p><a href="https://i.stack.imgur.com/wHUch.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ql2XO.jpg" /></a></p>

<p>After applying the ingress, the subdomains stop working:</p>

<p><a href="https://i.stack.imgur.com/f5ZNG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GRQF3.jpg" /></a></p>

<p><a href="https://i.stack.imgur.com/ys7TD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gORXI.jpg" /></a></p>

<p>Why does this happen?
I would like to access stuff in <code>shiny</code>, from <code>web</code>, through url's.
Eg. <code>&lt;iframe src=.../shiny/test1&gt;&lt;/iframe&gt;</code>.</p>

djfinnoy
<p>The following yaml adjustments solved the problem:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
  - http:
      paths:
      - path: /*
        backend:
          serviceName: web
          servicePort: 80
      - path: /shiny(/|$)(.*)
        backend:
          serviceName: shiny
          servicePort: 3838
</code></pre>

<p>Source: <a href="https://kubernetes.github.io/ingress-nginx/examples/rewrite/" rel="nofollow noreferrer">https://kubernetes.github.io/ingress-nginx/examples/rewrite/</a></p>

<p>Edit:</p>

<p>The above led to more trouble down the line. In the end, I went with the following ingress config:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/configuration-snippet: |
      rewrite /$1 break;
      rewrite /shiny/(.*) /$1 break;
spec:
  rules:
    - http:
        paths:
          - path: /
            backend:
              serviceName: web
              servicePort: 80
          - path: /shiny
            backend:
              serviceName: shiny
              servicePort: 3838
</code></pre>
