Ingress Controller Configuration for backend service with relative path

What is the best way to route traffic to a backend web front service which uses different relative paths within the web application.

As an example, take a standard Jaeger service kubectl create -f https://tinyurl.com/yc52x6q5.

I would like to expose this service end point via an ingress controller, see ingress configuration below

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: frontend-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
    nginx.ingress.kubernetes.io/add-base-url: "true"
spec:
  rules:
    - host:
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: frontend
                port:
                  number: 4444
          - path: /jaeger
            pathType: Prefix
            backend:
              service:
                name: jaeger-query
                port:
                  number: 443

  

Using ingress endpoint https://<host public ip>/jaeger, I am able to successfully invoke the backend service (jaeger-query), however the backend service pages with the relative URLs (like /static and /api) are not getting loaded/rendered on the browser as ingress controller does not have a rule to route that traffic.

As a workaround, I added ingress rules for /static and /api to point to the same backend service. configuration.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: frontend-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
    nginx.ingress.kubernetes.io/add-base-url: "true"
spec:
  rules:
    - host:
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: frontend
                port:
                  number: 4444
          - path: /jaeger
            pathType: Prefix
            backend:
              service:
                name: jaeger-query
                port:
                  number: 443
          - path: /search
            pathType: Prefix
            backend:
              service:
                name: jaeger-query
                port:
                  number: 443
          - path: /static
            pathType: Prefix
            backend:
              service:
                name: jaeger-query
                port:
                  number: 443
          - path: /api
            pathType: Prefix
            backend:
              service:
                name: jaeger-query
                port:
                  number: 443

Ideally, I would like one Ingress rule per backend service and the relative paths like /static and /api to automatically adjusted to /jaeger/static and /jaeger/api.

Do you know how that can be achieved?

Hello, did you find any solution for this issue ?

Yes. I had the same issue and adding the following annotiation made Jaeger UI work for me:

    nginx.ingress.kubernetes.io/configuration-snippet: |
      proxy_set_header Accept-Encoding ""; # sub_filter needs disabled compression
      sub_filter_once on;
      sub_filter '<base href="/"' '<base href="/jaeger/"';