An open API service indexing awesome lists of open source software.

https://github.com/api7/envoy-apisix


https://github.com/api7/envoy-apisix

Last synced: 10 months ago
JSON representation

Awesome Lists containing this project

README

          

# About

A Lua framework that support [Apache APISIX](https://github.com/apache/apisix) plugins run directly in [Envoy](https://github.com/envoyproxy/envoy) Lua filter without modify Envoy.

# Example

1. clone the code
```shell
git clone https://github.com/api7/envoy-apisix.git
```

2. build and run the example
```shell
$ cd envoy-apisix/example
$ docker-compose pull
$ docker-compose up --build -d
```

3. test the example

```shell
$ 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
```

# Plugins

* [redirect](docs/plugins/redirect.md): URI redirect.
* [referer-restriction](docs/plugins/referer-restriction.md): Referer whitelist.
* [uri-blocker](docs/plugins/uri-blocker.md): Block client request by URI.
* [ip-restriction](docs/plugins/ip-restriction.md): Restrict access by IP addresses.

# How does it work

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.

![Architecture](https://lh5.googleusercontent.com/iwtuR_yrBWeWLVM7Hfo1BTMNkP3-CY7iVqzvNwgIslnFc2GsUgr1_BRWi2em_fFhuqg8l3MuDAYMa7zM1mrkYzb4ynqg62WV6CvkOaY_wl4D-vRZKpUYayKh4DrgqDRl2NiTKOdq)

# Plugin workflow

![Architecture](https://lh5.googleusercontent.com/_zb5QqAqtyN0H3brtdRUFEPKMuat3dR5y3J-2V79yFBY7yU5VYfGHCT9cjxbsIVUbvbTgyE0bgfks6hHiIkawjXKXvN0bP_Fre8byMLTx-uPBbAkufDxlsV0GkqrOhZzHUvF3b9-)

We use the example to show how the plugin runs:

## First step, read configuration

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.

## Second step, parse request

We encapsulated the client request data into `ctx` so that it can be used directly in the entire process.

## Third step, run the plugin

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.