<p>I am abit confused on the kubernetes nginx virtual subroute. <a href="https://docs.nginx.com/nginx-ingress-controller/configuration/virtualserver-and-virtualserverroute-resources/#virtualserverroute-subroute" rel="nofollow noreferrer">https://docs.nginx.com/nginx-ingress-controller/configuration/virtualserver-and-virtualserverroute-resources/#virtualserverroute-subroute</a></p>
<blockquote>
<p>&quot;In the case of a prefix, the path must start with the same path as the path of the route of the VirtualServer that references this resource&quot;</p>
</blockquote>
<pre><code>path: /coffee
action: 
    path: coffee
</code></pre>
<p>will the /coffee be passed to the app?</p>
<p>because when I try to deploy the virtualserver with the route it doesn't work (exmaple below)</p>
<pre><code>path: /one
action: 
    path: hellok8s
</code></pre>
<p>however, this route that I am using previously is working</p>
<pre><code>path: /
action: 
    path: hellok8s
</code></pre>
<p>So taking for example, if I have an app-1 and app-2... Should I differentiate them through the host or through a sub-path?</p>
<ul>
<li>app-1: helloworld.test.com</li>
<li>app-2: helloworld2.test.com</li>
</ul>
<p>or is there way that I can differentiate them through path like below?</p>
<ul>
<li>app-1: helloworld.test.com/appone</li>
<li>app-2: helloworld.test.com/apptwo</li>
</ul>
<p>--- edit</p>
<pre><code>apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
  name: hellok8s-app-vs
spec:
  host: helloworld.moonshot.com
  tls:
    secret: nginx-tls-secret
    # basedOn: scheme
    redirect:
      enable: true
      code: 301
      upstream:
  - name: hellok8s
    service: hellok8s-service
    port: 8080
  routes:
  - path: /one
    action:
      proxy:
        upstream: hellok8s
        rewritePath: /
</code></pre>

rosepalette
<p>So the path is the URL which will be exposed by the Nginx to world outside. What happens to that path internally depends on the action's sub attributes, some examples:</p>
<p>Here the <code>/coffee</code> is what end user sees but the request is sent to root of coffee service. So if the coffee would be a service in K8S running at 8080, the request will land at <code>coffee:8080</code></p>
<pre><code>path: /coffee
 action:
  pass: coffee
</code></pre>
<p>But there are more <a href="https://docs.nginx.com/nginx-ingress-controller/configuration/virtualserver-and-virtualserverroute-resources/#action" rel="nofollow noreferrer">actions</a>. And let's say you use the <a href="https://docs.nginx.com/nginx-ingress-controller/configuration/virtualserver-and-virtualserverroute-resources/#action-proxy" rel="nofollow noreferrer"><code>action.proxy</code></a> then you can define at a lot more granular level what should happen with path. So in below example, we are forwarding to the <code>coffee</code> service but the request path is being re-written to <code>filtercoffee</code></p>
<pre><code>proxy:
  upstream: coffee
  rewritePath: /filtercoffee 
</code></pre>
<p>You can also use redirect, return in action's pass directive, but you must <a href="https://docs.nginx.com/nginx-ingress-controller/configuration/virtualserver-and-virtualserverroute-resources/#action" rel="nofollow noreferrer">use one of the four listed here</a></p>
