Istio Ingress Gateway - https and path based routing

Hi All, Hope you are doing fine…

We are trying to implement path based routing using Istio ingress controller (Gateway and Virtualservice) along with https (SSL). Our application is react based SPA and it expects “/” instead of any path. We want to have a single host and wants to pass appname as parameter in URL to reach to the app…like https://test.abcd.com/app1 and https://test.abcd.com/app2...Now if we are defining “/app1 or /app2” in virtual service as a routing rule instead of “/”, SPA is not getting loaded and we are getting 404.

One solution could be some rewrite rule but unable to make it successful yet…

Another solution is we can have dedicated host for each app/service. but the problem with it is we will need separate certificate for each host and that we don’t want. Wild card certificate could be an option but may not be approved by security.

Can you please provide your expert advise?

1 Like

yes you need to add a rewrite rule

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: apps-route
spec:
  hosts:
  - test.abcd.com
  http:
  - name: "app1"
    match:
    - uri:
        prefix: "/app1"
    rewrite:
      uri: "/"
    route:
        - destination:
            host: app1.ns.svc.cluster.local
  - name: "app2"
    match:
    - uri:
        prefix: "/app2"
    rewrite:
      uri: "/"
    route:
        - destination:
            host: app2.ns.svc.cluster.local
1 Like

I wish it be that simple :slight_smile: I already added rewrite the way you have described above, problem is application UI is based on React and it expects “/” but the backend is based on nodejs and it expects full path with /app1.

It seems like you need to layout / configure your applications and matching routes to be more effective. Your UI most likely can be configured to listen on different endpoints.

1 Like

@Mohd_Aslam I am also facing the same issue. How did you resolve this issue? If possible could you please share some inputs?