Skip to content

Strip path prefix #313

@rehmatworks

Description

@rehmatworks

I have this ingress for the NGINX ingress class, and it works fine. I need to strip the /api prefix, and this solution works fine for me. But I can't get a similar result when using Caddy:

NGINX ingress (Working):

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: authreact
  annotations:
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  tls:
  - hosts:
    - acme.example.com
    secretName: authreact-tls
  rules:
  - host: acme.example.com
    http:
      paths:
      - path: /api(/|$)(.*)
        pathType: ImplementationSpecific
        backend:
          service:
            name: authservice
            port:
              number: 8000
      - path: /
        pathType: Prefix
        backend:
          service:
            name: authreact
            port:
              number: 80

My current Caddy ingress:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: caddy-ingress
  annotations:
    kubernetes.io/ingress.class: caddy
spec:
  ingressClassName: caddy
  rules:
  - http:
      paths:
      - path: /api
        pathType: Prefix
        backend:
          service:
            name: authservice
            port:
              number: 8000
      - path: /
        pathType: Prefix
        backend:
          service:
            name: authreact
            port:
              number: 80

Is there any annotation or any other simple solution like Nginx Ingress? All requests received at authservice contain the /api prefix with Caddy, but I don't want to have that prefix. Any help will be highly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions