envoy serving a static response

Besides routing and redirecting you can serve static responses with Envoy.

In this case I want to serve a forbidden response (403)

route_config:
   virtual_hosts:
   – name: picockpit
     domains: [“picockpit.local:443”, “picockpit.local”]
     routes:
       – match: { prefix: “/demo” }
         direct_response:
           status: 403
           body:
             inline_string: “Forbidden.”

       – match: {prefix: “/”}
         route: {cluster: target_picockpit}

It can also serve up files from the local filesystem as a response.

Ref:

PS. If you get the error

error initializing configuration ‘/etc/envoy/envoy.yaml’: Unable to parse JSON as proto (INVALID_ARGUMENT:(route_config.virtual_hosts[0].routes[2].direct_response.body): invalid value “Forbidden.” for type type.googleapis.com/envoy.api.v2.core.DataSource), you are trying to set the string directly on body – you have to set it as a sub-value of inline_string of body. see my sample above.