Search code examples
istio

Istio - redirect to https external url


I'm trying to setup a simple redirect (not a proxy pass) in istio:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: test
spec:
  gateways:
  - test
  hosts:
  - test.com
  http:
  - redirect:
      authority: testredirect.com
      redirectCode: 302
---
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  name: test
spec:
  selector:
    istio: ingressgateway
  servers:
  - hosts:
    - test.com
    port:
      name: http
      number: 80
      protocol: HTTP2

This creates a redirect to http://testredirect.com

How do I get this to redirect to http**s**://?

Notes:

  1. I tried adding a DestinationRule and ServiceEntry, but that did not help
  2. we terminate SSL at the load balancer, so our requests come on port 80 non-encrypted

Solution

  • You can try adding the response header with key as location and value as "https://testredirect.com" in the VirtualService.

    redirect:
      authority: "testredirect.com"
    headers:
      response:
        set:
          location: "https://testredirect.com"