<p>I'm trying to expose a website inside my Kubernetes Cluster. Therefor I created an Ingress that links to my Service and so to my Pod. Till this point, everything works perfectly fine.
But now when I start navigating on my Page the URL changes, but the shown site stays the “Homepage”.
How is it possible to navigate on the page and access all the subpages properly?</p>
<p>My Deployment:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: wichteln-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: wichteln
  template:
    metadata:
      labels:
        app: wichteln
    spec:
      containers:
      - image: jonasgoetz01/website:V1.0
        name: wichteln-container
        command: [&quot;/bin/sh&quot;]
        args:
          - -c
          - &gt;-
              apt update
</code></pre>
<p>My Service:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: wichteln-service
spec:
  selector:
    app: wichteln
  ports:
    - protocol: TCP
      port: 5000
      targetPort: 5000
</code></pre>
<p>My Ingress:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: wichteln-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: public
  rules:
    - http:
        paths:
          - path: /wichteln/*
            pathType: Prefix
            backend:
              service:
                name: wichteln-service
                port:
                  number: 5000
</code></pre>
<p>The Webpage is a NodeJS express Webpage.
Here is my routes.js file for reference (If you need more files, please let me know):</p>
<pre class="lang-js prettyprint-override"><code>const express = require('express');
const router = express.Router();
const controller = require('../controllers/controller');

// Routes
router.get('/', controller.home);

router.get('/usermanagement/', controller.viewuser);
router.post('/usermanagement/', controller.finduser);
router.get('/usermanagement/adduser', controller.formuser);
router.post('/usermanagement/adduser', controller.createuser);
router.get('/usermanagement/edituser/:id', controller.edituser);
router.post('/usermanagement/edituser/:id', controller.updateuser);
router.get('/usermanagement/viewuser/:id', controller.viewalluser);
router.get('/usermanagement/:id',controller.deleteuser);
  
module.exports = router;
</code></pre>
<p>Every time I try to access the page, I start at the homepage. When I click on some buttons that normally would redirect me to a subpage, I stay at the homepage even if the URL changes correctly.
For example, the home URL is: <code>www.mydomain.com/wichteln</code> → I can see the homepage.
<code>www.mydomain.com/wichteln/usermanagement</code> → I can still see the homepage but want to see the subpage “usermanagement”.</p>
<p>Thank you for your help.</p>

Jonas Götz
<p>The issue is most likely coming from the rewrite that you have in your ingress manifest.</p>
<pre><code>    nginx.ingress.kubernetes.io/rewrite-target: /
</code></pre>
<p>this means that when the ingress receives the request from the client it takes the <code>path</code> portion of the url and rewrites it to be <code>/</code>, before passing it down to your backend, which in turn results in backend returning the root page of your website.</p>
