Hi Team, I am trying to create a Virtual Service and using a Regex in StringMatch for URI under HTTPMatchRequest.
But somehow I keep getting 404/302. Please see the below Virtual Service YAML file and logs from my gateway.
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: monitoring-prometheus-vs
namespace: monitoring
spec:
gateways:
- istio-system/ing-gateway
hosts:
- '*'
http:
- match:
- uri:
regex: '\/prometheus\/*'
rewrite:
uri: /
route:
- destination:
host: prometheus-ope-prometheus.monitoring.svc.cluster.local
Ingress Gateway Logs:
{"request_id":"09c6f1e8-6675-438f-a960-d26d90f1481b","authority":"******","method":"GET","path":"/prometheus","connection_termination_details":null,"response_code_details":"via_upstream","upstream_transport_failure_reason":null,"protocol":"HTTP/1.1","response_flags":"-","response_code":302,"duration":0,"upstream_cluster":"outbound|9090||prometheus-ope-prometheus.monitoring.svc.cluster.local","start_time":"2022-06-22T07:10:19.467Z","downstream_local_address":"10.205.54.56:8080","x_forwarded_for":"72.163.220.53,10.205.44.222","upstream_local_address":"10.205.54.56:52318","bytes_sent":40,"bytes_received":0,"upstream_service_time":"0","requested_server_name":null,"user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:101.0) Gecko/20100101 Firefox/101.0","upstream_host":"10.205.63.161:9090","route_name":null}
I am really struggling here, can someone please let me know what’s wrong? I have validated the regex and it matches what I need.