Gloo allows you to specify redirects instead of routes to a destination.
This guide assumes you’ve installed Gloo into the
gloo-system namespace, and
glooctl is installed to your machine.
Let’s also make sure
$GATEWAY_URL is set in your terminal:
export GATEWAY_URL=$(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 “google.com”:
apiVersion: gateway.solo.io/v1 kind: VirtualService metadata: name: test-redirect namespace: gloo-system spec: virtualHost: domains: - 'foo' routes: - matcher: prefix: / redirectAction: hostRedirect: "google.com"
Now if we curl the route, we should get a 301 Permanently Moved response.
curl -v -H "Host: foo" $GATEWAY_URL/
This will contain the following message:
< HTTP/1.1 301 Moved Permanently < location: http://google.com/
A virtual service route can be configured with a redirect instead of a routing action.
Let’s clean up the virtual service we created: