Ingress Controller Configuration for backend service with relative path

Sergey A. Osokin osa at freebsd.org.ru
Thu Jun 17 19:32:45 UTC 2021


Hi Vishal,

hope you're doing well.

Correct me if I'm wrong here but his configuration is related to
NGINX Ingress Controller from Kubernetes project, right?
If so, I'd recommend to contact to that project.

In case of NGINX OSS or NGINX Plus Ingress Controller from NGINX Inc.
please visit the following page to get contact information,
https://github.com/nginxinc/kubernetes-ingress/

Thank you.

--
Sergey Osokin

On Wed, Jun 16, 2021 at 08:21:47PM -0700, Vishal Mehra wrote:
> 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 endpoint via an ingress controller, see
> ingress configuration below
> 
> apiVersion: networking.k8s.io/v1kind: Ingressmetadata:
>   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/v1kind: Ingressmetadata:
>   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 adjust to /jaeger/static and
> /jaeger/api.
> 
> Do you know how that can be achieved?

> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx



More information about the nginx mailing list