Istio VirtualService HTTPRedirect to https

Hi,

How can I specify that a redirect is done via HTTPS in a Virtual Service?

The HttpRedirect doesn’t seem to have any configuration about that, and if I create a Virtual Service like this:

...
  http:
  - match:
    - uri:
        exact: /redirect
    redirect:
      authority: somedomain.com
      uri: /redirected
...

With a request to /redirect, I get a < location: http://somedomain.com/redirected.

To get around this, I created an Envoy Filter with this:

function envoy_on_request(request_handle)
  local headers = request_handle:headers();
  local path = headers:get(":path")
  local pathWithoutQueryString = string.match(path,"^([^%?]+)")

  if pathWithoutQueryString:match("^/redirect$") then
    local qstring = string.match(path,"(%?.*)")
    request_handle:respond({[":status"] = "301", ["Location"] = "https://somedomain.com/redirected" .. (qstring or "") }, "301 Moved Permanently")
  end
end

This works, but I think it’s better to mantain this in Virtual Service.

Is there any way to do this without EnvoyFilter?

You want probably want TLS origination