Kubernetes ingress-nginx ignore special characters in path

I’m trying to have a rule listening to a specific path containing a dollar sign like this:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: metadata-ingress
  annotations:
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/use-regex: "false"
spec:
  ingressClassName: public
  tls:
  - hosts:
    - mydomain.com
  rules:
  - host: mydomain.com
    http:
      paths:
      - path: /api/v2/$metadata
        pathType: Prefix
        backend:
          service:
            name: busybox
            port:
              number: 8280

I don’t want any url rewrite or anything fancy, just want this specific path to be caught and forwarded to this service.

Without the “$” it works.

I thought disabling regex with use-regex: "false" would fix it, but no.

I also tried using the url encoded value for $ : %24metadata but it doesn’t help either.

I also tried to use “exact” instead of “prefix” as the pathType but no.

It seems that the issue occurs only if the cluster have a second ingress resource that have the nginx.ingress.kubernetes.io/rewrite-target annotation. Even if the rules doesn’t matches, it gets prioritized for the route of my other ingress with the $ sign.

I checked a diff of the resulting nginx.conf. As soon as ANY ingress resource have the annotation, no matter what path it haves as a rule or where it redirect, ALL the “location” parts of the nginx config get replaced from location = /… to location ~* “^/…”

See answer here (and comments of the answer):