Lua filter
Setup your sandbox environment with Docker and Docker Compose, and clone the Envoy repository with Git.
Used to make requests.
In this example, we show how a Lua filter can be used with the Envoy proxy.
envoy_on_request(request_handle)
envoy_on_response(response_handle)
for an overview of Envoy’s Lua filter and documentation regarding these functions.
Change to the examples/lua
directory.
Step 2: Send a request to the service
The output from the curl
command below should include the headers foo
.
$ curl -v localhost:8000
Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8000 (#0)
> GET / HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 200 OK
< content-length: 544
< etag: W/"220-IhsqVTh4HjcpuJQ3C+rEL1Cw1jA"
< date: Thu, 31 Oct 2019 03:13:24 GMT
< x-envoy-upstream-service-time: 1
< response-body-size: 544 <-- This is added to the response header by our Lua script. --<
< server: envoy
<
{
"path": "/",
"headers": {
"host": "localhost:8000",
"user-agent": "curl/7.64.1",
"accept": "*/*",
"x-forwarded-proto": "http",
"x-request-id": "a78fcce7-2d67-4eeb-890a-73eebb942a17",
"content-length": "0"
},
"method": "GET",
"body": "",
"fresh": false,
"hostname": "localhost",
"ip": "::ffff:172.20.0.2",
"ips": [],
"protocol": "http",
"query": {},
"subdomains": [],
"xhr": false,
"os": {
"hostname": "7ca39ead805a"
}
See also
Learn more about the Envoy Lua filter.
The Lua programming language.