Apache APISIX云原生 API 網(wǎng)關(guān)
APISIX 是一個(gè)云原生 API 網(wǎng)關(guān),是 Apache 軟件基金會(huì)的頂級項(xiàng)目。
APISIX 從 etcd 中訂閱獲取所需的配置并以熱更新的方式來更改自身行為,更改 etcd 中的配置即可完成對 APISIX 網(wǎng)關(guān)節(jié)點(diǎn)的控制,比如:動(dòng)態(tài)上游、請求限速等。
快速上手
- 啟動(dòng) APISIX
sudo apisix start
- 測試限流插件
為了方便測試,下面的示例中設(shè)置的是 60 秒最多只能有 2 個(gè)請求,如果超過就返回 503:
curl http://127.0.0.1:2379/v2/keys/apisix/routes/1 -X PUT -d value='
{
"methods": ["GET"],
"uri": "/index.html",
"id": 1,
"plugin_config": {
"limit-count": {
"count": 2,
"time_window": 60,
"rejected_code": 503,
"key": "remote_addr"
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"39.97.63.215:80": 1
}
}
}'
$ curl -i http://127.0.0.1:9080/index.html HTTP/1.1 200 OK Content-Type: text/html Content-Length: 13175 Connection: keep-alive X-RateLimit-Limit: 2 X-RateLimit-Remaining: 1 Server: APISIX web server Date: Mon, 03 Jun 2019 09:38:32 GMT Last-Modified: Wed, 24 Apr 2019 00:14:17 GMT ETag: "5cbfaa59-3377" Accept-Ranges: bytes ...
評論
圖片
表情
