microgateway 一些参考资料
microgateway 是apigee 开源的自家edgemicro gateway,目前github 上的信息不是很全,以下是一些整理
配置
microgateway 是需要配置管理的,但是github相关文档很少,如果需要参考(合理上网)
https://docs.apigee.com/api-platform/microgateway/edge-microgateway-home,最好还是看下官方文档
- 一个参考配置
注意此配置部分的plugin 是基于官方的,实际我们如果直接使用microgateway-core,plugin 部分需要调整下
edge_config:
bootstrap: https://apigee.net/edgemicro/bootstrap/organization/org/environment/env...
jwt_public_key: http://apigee.net/edgemicro/publicKey...
managementUri: https://api.enterprise.apigee.com
vaultName: microgateway
authUri: https://%s-%s.apigee.net/edgemicro-auth
baseUri: https://edgemicroservices.apigee.net/edgemicro/%s/organization/%s/environment/%s
bootstrapMessage: Please copy the following property to the edge micro agent config
keySecretMessage: The following credentials are required to start edge micro
edgemicro:
port: 8000
max_connections: 1000
config_change_poll_interval: 600
logging:
level: error
dir: /var/tmp
stats_log_interval: 60
rotate_interval: 24
stack_trace: false
plugins:
sequence:
- oauth
headers:
x-forwarded-for: true
x-forwarded-host: true
x-request-id: true
x-response-time: true
via: true
oauth:
allowNoAuthorization: false
allowInvalidAuthorization: false
gracePeriod: 10
扩展插件
这个github 上也已经开源了,同时也已经提供了很多,可以直接使用,具体每个插件的配置进入插件目录就可以看了
参考https://github.com/apigee/microgateway-plugins ,如下https://github.com/apigee/microgateway-plugins/tree/master/extauth
readme 就包含了插件的使用,注意有些可能没有,但是插件的模型很简单,看看代码也行,如果看了官方edgemicro的代码,内置插件
的注册就是类似如下模式注册的
- 一个参考plugin 的使用
package.json
{
"name": "edge-gayeway",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"config": "^3.3.1",
"debug": "^4.1.1",
"microgateway-core": "^3.1.4",
"microgateway-plugins": "^3.0.14"
},
"scripts": {
"start": "DEBUG=* node app.js"
}
}
配置
config/default.yaml
edgemicro:
port: 3000
logging:
level: warn
proxies:
- base_path: /
url: http://localhost:8080
代码引用plugin
'use strict'
const debug = require('debug')('test')
const microgateway = require('microgateway-core')
// 引用内置的cors plugin
const cors = require("microgateway-plugins/cors")
const config = require('config')
const gateway = microgateway(config)
debug('starting gateway')
// 添加plugin
gateway.addPlugin("cors",cors.init)
console.log("plugins",gateway.plugins.toString())
gateway.start((err, server) => {
if (err) {
debug('gateway err %o', err)
process.exit(1)
}
debug('gateway started')
})
说明
目前microgateway文档不是很全,但是整体代码不难,我们可以参考学习下
参考资料
https://www.npmjs.com/package/edgemicro
https://github.com/apigee/microgateway-core
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2019-05-31 使用vault pki 为nginx 生成tls 证书文件
2019-05-31 使用vault pki engine 方便的管理证书
2018-05-31 ballerina 学习十七 多线程编程
2017-05-31 drill 数据源配置
2017-05-31 drill java && spring jdbc 连接使用
2017-05-31 drill 试用
2015-05-31 css 动画类库Animate.css