Redirecting to an external site using istio virtual service

5/17/2020

I have two endpoints

  1. www.site.com -> IP1
  2. site.com -> IP2

Both these endpoints are pointing to two different IPs. The endpoint www.site.com is not running inside the k8s cluster.

Whenever anyone hits site.com, I want it to automatically redirect to www.site.com. So, I have the following config

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: my-vs
  namespace: dev
spec:
  hosts:
  - site.com
  http:
  - match:
    - authority:
        exact: site.com
    redirect:
      authority: www.site.com

However, this gives me a 404 error. What is the correct way to achieve this?

-- kosta
istio
kubernetes

0 Answers