Cannot access ingress subpath using nginx

6/3/2019

I have a containerized application that I deployed to kubernetes, and I'm now working on a ingress route to add to my ingress controller so I can access the application from outside the cluster.

My application has an index root and this page contains hyperlinks for other pages. When creating the ingress route I can access the index page eg. /something, but then when I click on an hyperlink which would direct me to a new page /something/new, I get instead /new .

Accessing the pod directly I can navigate through the application just fine.

I tried changing the annotation and the regex code on the paths but nothing seems to work so far.

Here's my ingress:

metadata:
  name: something-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  rules:
  - http:
      paths:
      - backend:
          serviceName: svc-something
          servicePort: 8000
        path: /something(/|$)(.*)

Expected to access the path /something/new but get /new instead. Did anyone run into the same issue?

-- NFDS
kubernetes
kubernetes-ingress
kubernetes-pod
nginx
nginx-reverse-proxy

0 Answers