Istio gateway Not launching internal links, how to fix that?

I have deployed application in kubernetes. It is working if we expose to a default load balancer service in azure kubernetes. But, after setting a virtual service linked with istio ingress gateway, it is launching only the home page, none of the links are working like /admin /login.

I have added entries for /admin and /login already in virtual service but it is not opening those pages.

kiali launched using

istioctl dashboard kiali

When I check logs in kiali.

[2021-07-18T08:19:51.304Z] "GET /admin/ HTTP/1.1" 404 NR route_not_found - "-" 0 0 0 - "10.244.1.1" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36" "bc1ce347-4151-947b-b3d5-4c08003889a2" "20.85.0.248" "-" - - 10.244.1.9:8080 10.244.1.1:4441 - -

[2021-07-18T08:19:53.400Z] "GET /login/ HTTP/1.1" 404 NR route_not_found - "-" 0 0 0 - "10.244.1.1" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36" "78f9d59e-6126-94f6-99e3-cbffe98e274f" "20.85.0.248" "-" - - 10.244.1.9:8080 10.244.1.1:4441 - -

[2021-07-18T08:19:56.286Z] "GET /login HTTP/1.1" 301 - via_upstream - "-" 0 0 4 4 "10.244.1.1" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36" "be2ff6b8-751d-9150-9d6a-936a436f7fef" "20.85.0.248" "10.244.1.50:3000" outbound|8080||node-service.default.svc.cluster.local 10.244.1.9:59678 10.244.1.9:8080 10.244.1.1:4441 - -

[2021-07-18T08:19:56.525Z] "GET /login/ HTTP/1.1" 404 NR route_not_found - "-" 0 0 0 - "10.244.1.1" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36" "f821db0b-cc9d-9b8c-9769-71ac7636a87e" "20.85.0.248" "-" - - 10.244.1.9:8080 10.244.1.1:4441 - -

[2021-07-18T08:20:00.198Z] "GET / HTTP/1.1" 200 - via_upstream - "-" 0 2804 4 4 "10.244.1.1" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36" "43c37e75-f0ce-9474-bc4d-ea4459772f6d" "20.85.0.248" "10.244.1.50:3000" outbound|8080||node-service.default.svc.cluster.local 10.244.1.9:59678 10.244.1.9:8080 10.244.1.1:4441 - -

[2021-07-18T08:20:00.457Z] "GET /static/todo/logo.png HTTP/1.1" 404 NR route_not_found - "-" 0 0 0 - "10.244.1.1" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36" "a26d3710-3868-96b6-9d6d-7f6ee05dc131" "20.85.0.248" "-" - - 10.244.1.9:8080 10.244.1.1:4441 - -

[2021-07-18T08:20:34.337Z] "GET /login/ HTTP/1.1" 404 NR route_not_found - "-" 0 0 0 - "10.244.1.1" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36" "e8e73933-f95e-90a7-bdf4-ad39352982c5" "20.85.0.248" "-" - - 10.244.1.9:8080 10.244.1.1:4441 - -

[2021-07-18T08:20:37.506Z] "GET /login/ HTTP/1.1" 404 NR route_not_found - "-" 0 0 0 - "10.244.1.1" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36" "bee90116-2d78-99dd-a4b7-fede0641fed8" "20.85.0.248" "-" - - 10.244.1.9:8080 10.244.1.1:4441 - -

[2021-07-18T08:20:40.191Z] "GET /login/ HTTP/1.1" 404 NR route_not_found - "-" 0 0 0 - "10.244.1.1" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36" "f9df634e-743f-9699-a85d-40926db41ca4" "20.85.0.248" "-" - - 10.244.1.9:8080 10.244.1.1:4441 - -

Please suggest how to fix this?

The sample app docker link.

The kubernetes yaml files used:

Deployment.yaml

apiVersion: v1
kind: Service
metadata:
  name: node-service
  labels:
    app: nodeapp
    service: node-service
spec:
  selector:
    app: nodeapp
  ports:
    - name: http
      port: 8080
      targetPort: 3000 #80

---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: nodeapp-details
  labels:
    account: nodeapp-details
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nodeapp-deployment
  labels:
    app: nodeapp
    version: v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nodeapp
      version: v1
  template:
    metadata:
      labels:
        app: nodeapp
        version: v1
    spec:
      serviceAccountName: nodeapp-details
      containers:
        - name: nginx
          image: uday1kiran/todoapp:1.0 #nginx
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 3000 #80
              name: nodeapp-port
          #securityContext:
          #runAsUser: 1000

virtualservice.yaml

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: nodeserver
spec:
  hosts:
    - "*"
  gateways:
    - node-gateway
  http:
    - match:
        - uri:
            exact: /
        - uri:
            exact: /admin
        - uri:
            exact: /login
      route:
        - destination:
            host: node-service
            port:
              number: 8080

gateway.yaml

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: node-gateway
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"

Is there any redirect call or it is can api .
You try prefix instead of exact and give a try

It is able to access the admin page now.
I mean, the /admin if I change the type match from exact to prefix.

But the styles are not getting loaded.

And also if I click any hyperlinks available on the homepage of app, they won’t work again.

And also there is one more reactjs app, where it won’t show the page at all, just an empty page from istio.

Is your server redirecting requests with a URI path of /admin to a URI path of /admin/? Try having two ORed exact matches, one for /admin and one for /admin/. (Or use an equivalent single regular-expression match.) Does that work?

Daniel