A Lua framework that support Apache APISIX plugins run directly in Envoy Lua filter without modify Envoy.
clone the code
git clone https://github.com/api7/envoy-apisix.git
build and run the example
$ cd envoy-apisix/example
$ docker-compose pull
$ docker-compose up --build -d
test the example
$ curl 127.0.0.1:8000/foo/root.exe -i
HTTP/1.1 403 Forbidden
server: envoy
content-length: 0
date: Wed, 18 Nov 2020 00:08:54 GMT
We shield platform differences for the plugin layer. All interfaces that need to be used are abstracted in the underlying framework, which we call apisix.core, so that all plugins can run on Envoy and Apache APISIX at the same time.
We use the example to show how the plugin runs:
We configure through metadata to determine what plugins need to run on each route and what configuration is for each plugin.
In the example, we configured plugin uri-blocker
for the route whose prefix is /foo
, as well as the block rule of the plugin and the response status when a block is required.
We encapsulated the client request data into ctx
so that it can be used directly in the entire process.
We determine whether we need to block this request by matching the configured rules and the obtained uri. If a block is needed, we call respond
to directly respond, otherwise we let it go.