<p>I am attempting to use an ingress controller within k8s to access my web servers running within the cluster. I am testing using path based routing ingress resources, and testing by accessing a worker IP address (as the ingress is using a node port service accessible through any of the worker nodes). </p>

<p>When I access other test  web applications (without a login page), I am able to access my service as the following:
http://{worker-ip}:{ingress-node-port}/{svc-name}</p>

<p>When I am trying to access an application that has a login page, I am redirected to the following after entering the above:
http://{worker-ip}/vui/login</p>

<p>This obviously does not redirect me to the correct login page, and I am shown an error on the screen. Is there any way to hold the path and port name throughout this process so that the /vui/login path is sent with the correct service name and port number? If I input the entire path directly, I am still not able to access the service. I am thinking that since the path is changed to the correct login page, but cannot actually access the service, the redirection is working up to a certain point, and then failing out once the URL is changed to not use the path and service name.</p>

<p>Any advice on ingress, path based routing, and using them both with a login page redirection would be much appreciated.</p>

<p>Below is the ingress definition that I am using in my testing:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress 
metadata: 
  name: test-ingress 
  annotations: ingress.kubernetes.io/rewrite-target: / 
spec: 
  rules: 
  - http: 
      paths: 
      - path: /test1 
      backend: 
        serviceName: test1-service 
        servicePort: 5678 
      - path: /test2 
      backend: 
        serviceName: test2-service 
        servicePort: 5678 
      - path: /test3 
      backend: 
        serviceName: test3-service 
        servicePort: 8080
</code></pre>

mmiara
<p>You can use the <strong>next</strong> URL parameter for your case. For example, you are entering </p>

<pre><code>https://example.com/test3
</code></pre>

<p>This redirects you to the login page if I've understood your problem correctly. The URL then becomes the login page URL - </p>

<pre><code>https://example.com/vui/login
</code></pre>

<p>In this case, the URL that it originally came from isn't preserved.</p>

<p>So, I think you can use the <strong>next</strong> parameter in your URL and redirect the route to that URL once the user is authenticated. The URL will be - </p>

<pre><code>https://example.com/vui/login?next=/test3/
</code></pre>

<p>Then you can deploy your k8s Ingress resource with the <strong>query-routing</strong> annotation -</p>

<pre><code>ingress.kubernetes.io/query-routing: default/query-routing
</code></pre>

<p>and add a ConfigMap from where the URL params will be exerted -</p>

<pre><code>kind:ConfigMap
apiVersion: v1
metadata:
  name: query-routing
data:
  mapping: |-
   [{
    "field": "login",
    "value": "1",
    "path": "/test3",
    "service": "test3-service ",
    "port": "8080"
   }]
</code></pre>
