Host Redirect

Gloo allows you to specify redirects instead of routes to a destination.


This guide assumes that you have deployed Gloo to the gloo-system namespace and that the glooctl command line utility is installed on your machine. glooctl provides several convenient functions to view, manipulate, and debug Gloo resources; in particular, it is worth mentioning the following command, which we will use each time we need to retrieve the URL of the Gloo Gateway that is running inside your cluster:

glooctl proxy url

Creating a redirect virtual service

Let’s create a virtual service with a redirect action instead of a route action, redirecting “foo” to “”:

kind: VirtualService
  name: test-redirect
  namespace: gloo-system
      - 'foo'
      - matchers:
         - prefix: /
          hostRedirect: ""

Now if we curl the route, we should get a 301 Permanently Moved response.

curl -v -H "Host: foo" $(glooctl proxy url)

This will contain the following message:

< HTTP/1.1 301 Moved Permanently
< location:


A virtual service route can be configured with a redirect instead of a routing action.

Let’s clean up the virtual service we created:

kubectl delete vs -n gloo-system test-redirect

glooctl delete vs test-redirect