<p>I have a website that uses relative href links (eg. the link directs to &quot;/login&quot;, rather than &quot;http://somesite.com/login&quot;). This works A-OK in a normal server but I'd like to use the website inside a docker container as part of a kubernetes cluster. My goal is to have multiple replicas of the website to manage high load times, defaulting to two nodes with dynamic scaling.</p>
<p>I set us the service as a 'loadbalancer' as follows:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: websiteservice
spec:
  selector:
    app: websiteapp
  type: LoadBalancer
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
</code></pre>
<p>The issue here is that if I navigate to the URL of the load balancer (that's automatically created at my host - digital ocean) then although the homepage of the website loads, any other pages give me a 404 because rather than loading the &quot;/login&quot; page of the container it loads the &quot;/login&quot; page of the load balancer which doesn't exist. How can I configure my cluster or load balancer to forward all subdirectories (anything after the .com) to the webserver?</p>
<p><strong>EDIT 1</strong>
In comments I was advised to set up ingress. I <em>think</em> I've done so with this change to my yaml:</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: somesite.co.uk
    http:
      paths:
      - backend:
          serviceName: websiteservice
          servicePort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: websiteservice
spec:
  selector:
    app: websiteapp
  type: ClusterIP
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: websiteapp
spec:
  replicas: 2
  selector:
    matchLabels:
      app: websiteapp
  template:
    metadata:
      labels:
        app: websiteapp
    spec:
      containers:
      - name: websiteapp
        image: mydocker.co.uk/websiteimg
      imagePullSecrets:
      - name: regcred
      nodeSelector:
        beta.kubernetes.io/instance-type: s-2vcpu-4gb
</code></pre>
<p>But I'm still not able to navigate beyond the home page of my website.</p>

FraserOfSmeg
<p>Your Ingress file should look like this:</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: somesite.co.uk
    http:
      paths:
      - path: /*
        backend:
          serviceName: websiteservice
          servicePort: 80
</code></pre>
<p>Simply you have add path to redirect traffic.</p>
<p>Take a look: <a href="https://kubernetes.github.io/ingress-nginx/user-guide/basic-usage/" rel="nofollow noreferrer">host-path-routing</a>, <a href="https://kubernetes.github.io/ingress-nginx/user-guide/ingress-path-matching/" rel="nofollow noreferrer">ingress-path-matching</a>.</p>
