0

I'm facing a very weird issue with Ingress Nginx. The Nginx was provisioned by RKE2 deployment as a daemonset (rke2-ingress-nginx-controller).

It works fine for any Ingress definition for which path points to / .

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: sealed-secrets-sealed-secrets-web
  namespace: sealed-secrets
spec:
  ingressClassName: nginx
  rules:
  - host: host.domain.com
    http:
      paths:
      - backend:
          service:
            name: sealed-secrets-sealed-secrets-web
            port:
              number: 80
        path: /
        pathType: Prefix

But if instead of "/", the path points to something different (e.g. /sealed-secrets), I get an error 404 (not found), even if rewrite-target set.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: sealed-secrets-sealed-secrets-web
  namespace: sealed-secrets
spec:
  ingressClassName: nginx
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
  rules:
  - host: host.domain.com
    http:
      paths:
      - backend:
          service:
            name: sealed-secrets-sealed-secrets-web
            port:
              number: 80
        path: /sealed-secrets
        pathType: Prefix

I'm using sealed-secrets to illustrate, but the same happens for whatever ingress resource defined.

Any help will be appreciated.

Hutger Hauer
  • 55
  • 1
  • 3

1 Answers1

0

It seems that I've missed the need for adding a regex to rewrite paths.

    annotations:
      nginx.ingress.kubernetes.io/ssl-redirect: 'false'
      nginx.ingress.kubernetes.io/use-regex: "true"
      nginx.ingress.kubernetes.io/rewrite-target: /$2
    # -- Ingress hosts
    hosts:
      - host: host.domain.com
        paths:
          - path: /sealed-secrets(/|$)(.*)
            pathType: Prefix

Now the connection is reaching the app and displaying the expected page.

Hutger Hauer
  • 55
  • 1
  • 3