For more information, see the Kubernetes Gateway API documentation.

Before you begin

  1. Follow the Get started guide to install Gloo Gateway, set up a gateway resource, and deploy the httpbin sample app.

  2. Get the external address of the gateway and save it in an environment variable.

Set up host redirects

  1. Create an HTTP route for the httpbin app that you created as part of the Get started guide. In the following example, requests for the host.redirect.example domain are redirected to the hostname, and a 302 HTTP response code is returned to the user.

      kubectl apply -f- <<EOF
    kind: HTTPRoute
      name: httpbin-redirect
      namespace: httpbin
        - name: http
          namespace: gloo-system
        - host.redirect.example
        - filters:
          - type: RequestRedirect
              hostname: ""
              statusCode: 302
  2. Send a request to the httpbin app on the host.redirect.example domain and verify that you get back a 302 HTTP response code and the redirect location

    Example output:

      * Mark bundle as not supporting multiuse
    < HTTP/1.1 302 Found
    HTTP/1.1 302 Found
    < location:
    < date: Sat, 04 Nov 2023 01:40:06 GMT
    date: Sat, 04 Nov 2023 01:40:06 GMT
    < server: envoy
    server: envoy
    < content-length: 0
    content-length: 0


You can optionally delete the HTTP route that you created as part of this guide.

  kubectl delete httproute httpbin-redirect -n httpbin