Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
b56747c
colloct requrest and response info by kafaka
noname007 May 11, 2017
f95e542
fix phase bug: 1. Api disabled in log phrase 2.access phrase could no…
noname007 May 11, 2017
4f56497
ajust style && del a invalid var
noname007 May 11, 2017
de2d618
1. fix: name error. 2: compliant with plug dynamic_upstream 3:refact:…
noname007 Jun 12, 2017
c0c26a1
1.fix: kafka deps; 2.add the server_addr to log
noname007 Jul 12, 2017
b4d8671
support cookie condition judge & variable extractor
sumory Aug 5, 2017
c2a7a52
port kong's ring-balancer to orange
zhjwpku Aug 2, 2017
67ae295
fix some typo and coding style
zhjwpku Aug 3, 2017
39fd529
wheelsize => wheelSize
zhjwpku Aug 3, 2017
3d3b1c1
take host's enable field into account
zhjwpku Aug 7, 2017
fefec05
add Balancer UI
zhjwpku Aug 9, 2017
2175315
fix bug
zhjwpku Sep 1, 2017
e6c9ba3
fix bad log level
zhjwpku Oct 20, 2017
f5a0ef6
do some refactor
zhjwpku Nov 16, 2017
0cbd5ba
fix: the dashboard displays error
zhousoft Nov 25, 2017
c718ce1
fix bug - invalid URL prefix in ""
zhjwpku Dec 1, 2017
31e2afb
Alter selector continue behavior
zhjwpku Dec 14, 2017
aa9561c
a little refactor
zhjwpku Dec 14, 2017
b9de688
another refactor
zhjwpku Dec 14, 2017
dac233d
refactor some detail after merge some pr
sumory Jan 20, 2018
32c5aca
update some introduction
sumory Jan 20, 2018
6e9201f
refactor some log level
sumory Jan 20, 2018
4506afe
Completed persist log plugin
Jan 23, 2018
1c2fce9
Complete node manage plugin
imocat Jan 23, 2018
32b52d3
fix: lost create table sql in install sql file
imocat Jan 23, 2018
f368ca8
Merge pull request #177 from imocat/v0.7.0-dev-node
sumory Jan 28, 2018
898804a
Merge branch 'v0.7.0-dev' into v0.7.0-dev-persist
imocat Jan 29, 2018
858a720
add service discover support using consul
tyzam Jan 29, 2018
107a585
fix the persist log stat bugs
imocat Jan 31, 2018
f745993
fix persist empty data bug
imocat Jan 31, 2018
5881491
fix bug
zhjwpku Feb 27, 2018
638d27f
Merge pull request #191 from infracc/upstream-v0.7.0-dev
sumory Feb 27, 2018
5fc4f64
add mod judge condition
roronoaly Feb 28, 2018
8c6d4e0
Merge pull request #194 from roronoaly/add_mod_judge_feature-dev7.0
sumory Feb 28, 2018
1a8a489
balancer plugins need lua-resty-http and luasocket module
roronoaly Feb 28, 2018
0dd0f47
Merge pull request #196 from roronoaly/add_mod_judge_feature-dev7.0
sumory Mar 5, 2018
2d87857
Fix balancer bug
zhjwpku Mar 9, 2018
c51ea17
Merge pull request #199 from infracc/upstream-v0.7.0-dev
sumory Mar 9, 2018
0c534ae
Merge pull request #176 from imocat/v0.7.0-dev-persist
sumory Mar 14, 2018
7184d26
Merge pull request #181 from tyzamTsing/v0.7.0-dev
sumory Apr 17, 2018
8828360
加个随机选项,模拟RR
noname007 Sep 27, 2018
d3d1dcb
Del log
noname007 Sep 27, 2018
083e221
Random
noname007 Sep 28, 2018
7a64dd8
Del
noname007 Sep 28, 2018
4d60928
merge master
wujunze Mar 14, 2019
3917a97
Merge pull request #219 from noname007/feat/weight
wujunze Mar 16, 2019
1a00d33
Merge pull request #108 from thisverygoodhhhh/kafka-log-collect
wujunze Mar 17, 2019
c8bd418
使用正确的read timeout 参数。
Mar 20, 2019
19e4be3
Update handler.lua
EasonFeng5870 Mar 20, 2019
e86636e
Update handler.lua
EasonFeng5870 Mar 20, 2019
7586144
Merge pull request #233 from EasonFeng5870/v0.7.0-dev
wujunze Mar 21, 2019
ec1e09a
merge master
wujunze Mar 22, 2019
2696fd1
for https://github.com/sumory/orange/issues/236 and ignore case in si…
Mar 25, 2019
25eefa8
Merge pull request #239 from EasonFeng5870/v0.7.0-dev
wujunze Mar 25, 2019
5cb9d23
Merge remote-tracking branch 'origin/master' into v0.7.0-dev
wujunze Mar 26, 2019
2296195
release 0.7
wujunze Mar 26, 2019
effaa55
version 0.7.0
wujunze Mar 26, 2019
d53d7e3
add Contributors
wujunze Mar 26, 2019
83a4431
add Contributors
wujunze Mar 26, 2019
dead7db
Add HMAC Authorization Plugin
shuaijinchao Mar 30, 2019
8cdd366
Merge pull request #1 from shuaijinchao/plugins/hmac
shuaijinchao Mar 30, 2019
619d413
for https://github.com/sumory/orange/pull/240
Mar 31, 2019
d09434b
delete not-default plugin's configs.
Mar 31, 2019
4ba2c61
Merge remote-tracking branch 'origin/v0.7.0-dev' into plugins/hmac
shuaijinchao Mar 31, 2019
f33a5a9
Merge remote-tracking branch 'origin/master' into plugins/hmac
shuaijinchao Mar 31, 2019
143545c
hmac_auth sql updated from orange-0.6.4.sql to orange-0.7.0.sql
shuaijinchao Mar 31, 2019
e8a6e67
Merge pull request #2 from shuaijinchao/plugins/hmac
shuaijinchao Mar 31, 2019
96320d9
Merge pull request #241 from shuaijinchao/master
wujunze Apr 1, 2019
36b9702
Merge pull request #242 from dangdangdotcom/v0.7.0-dev
wujunze Apr 1, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
针对`Orange使用`的提问, 对于简单几句话描述不清的问题, 请使用以下格式, 不符合格式或描述含糊不清的issue将不予回复。
针对`Orange使用`的提问,对于简单几句话描述不清的问题,请使用以下格式,不符合格式或描述含糊不清的issue将不予回复。根据问题模板填写好后,提问之前请去除模板的无用内容。

##### 使用的Orange版本

如v0.7.0

##### 需求或场景

Expand All @@ -10,13 +14,13 @@

##### 具体的配置

在插件里做了什么配置, 可以截图, 一定要描述清楚你的配置
在插件里做了什么配置,可以截图,一定要描述清楚你的配置

##### 期望的结果

按你选用的插件和所做的配置, 你期望的结果是什么? 比如访问了哪个URL, 参数都是什么, 期望的输出是什么
按你选用的插件和所做的配置,你期望的结果是什么?比如访问了哪个URL,参数都是什么,期望的输出是什么

##### 错误的结果

描述实际的结果, 比如错误的输出或截图
描述实际的结果,比如错误的输出或截图

15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
### v0.7.0 2019

- 支持通过cookie、随机数、HTTP method进行拦截过滤
- 新增取余的方式进行匹配规则
- 新增kafka、balancer、consul_balancer、persist log、node插件
- 修复一些已知bug:后台页面展示异常
- 对后台页面、balancer等模块的代码和文档说明的重构
- 修复了issue#160,解决balancer开关未打开时出现invalid URL prefix in "" 的错误
- 修复了issue#162,解决选择器类型为1时continue=false的错误
- 修复了issue#233,解决proxy read timeout配置无效的问题
- 修复了issue#236,解决忽略大小写进行匹配鉴权值的问题
- 修改Makefile
- 使用指定版的依赖


### v0.6.4 2017.05.16

- 修复issue#110, 解决在添加/删除规则后本地js cache未更新,之后立刻更改选择器配置造成的规则丢失bug
Expand Down
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ init-config:
@ test -f conf/nginx.conf || (cp conf/nginx.conf.example conf/nginx.conf && echo "copy nginx.conf")
@ test -f conf/orange.conf || (cp conf/orange.conf.example conf/orange.conf && echo "copy orange.conf")

deps:init-config
mkdir -p resty
wget https://github.com/ledgetech/lua-resty-http/archive/v0.13.zip
unzip lua-resty-http-0.13.zip
yes|cp -fr lua-resty-http-0.13/lib/resty/* resty/
rm -fr lua-resty-http-0.13.zip lua-resty-http-0.13.zip
wget https://github.com/doujiang24/lua-resty-kafka/archive/v0.06.zip
unzip lua-resty-kafka-0.06.zip
yes|cp -fr lua-resty-kafka-0.06/lib/resty/* resty
rm -fr lua-resty-kafka-0.06.zip lua-resty-kafka-0.06

test:
@echo "to be continued..."

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ Find more about Orange on its [website](http://orange.sumory.com/docs). There is
- [@spacewander](https://github.com/spacewander)
- [@noname007](https://github.com/noname007)
- [@itchenyi](https://github.com/itchenyi)
- [@Near-Zhang](https://github.com/Near-Zhang)
- [@khlipeng](https://github.com/khlipeng)
- [@wujunze](https://github.com/wujunze)

### See also

Expand Down
56 changes: 29 additions & 27 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<a href="./README_zh.md" style="font-size:13px">中文</a> | <a href="./README.md" style="font-size:13px">English</a> | <a href="http://orange.sumory.com" style="font-size:13px">Website</a>

Orange是一个基于OpenResty的API网关。除Nginx的基本功能外,它还可用于API监控、访问控制(鉴权、WAF)、流量筛选、访问限速、AB测试、动态分流等。它有以下特性:
Orange是一个基于OpenResty的API网关。除Nginx的基本功能外,它还可用于API监控、访问控制(鉴权、WAF)、流量筛选、访问限速、AB测试、静/动态分流等。它有以下特性:

- 提供了一套默认的Dashboard用于动态管理各种功能和配置
- 提供了API接口用于实现第三方服务(如个性化运维需求、第三方Dashboard等)
Expand All @@ -16,23 +16,27 @@ Orange是一个基于OpenResty的API网关。除Nginx的基本功能外,它还

#### 安装依赖

- OpenResty: 版本应在1.9.7.3+
- Orange的监控插件需要统计http的某些状态数据,所以需要编译OpenResty时添加`--with-http_stub_status_module`
- 由于使用了*_block指令,所以OpenResty的版本最好在1.9.7.3以上.
- [lor](https://github.com/sumory/lor)框架
- OpenResty: 版本应在1.11.2+
- Orange的监控插件需要统计HTTP的状态数据,所以编译OpenResty时需要添加`--with-http_stub_status_module`
- [Lor](https://github.com/sumory/lor)框架
- 若使用的Orange版本低于v0.6.2则应安装lor v0.2.*版本
- 若使用的Orange版本高于或等于v0.6.2则应安装lor v0.3.0+版本
- MySQL
- 配置存储和集群扩展需要MySQL支持。从0.2.0版本开始,Orange去除了本地文件存储的方式,目前仅提供MySQL存储支持.
- 配置存储和集群扩展需要MySQL支持
- 使用luarocks安装一些第三方库
- luarocks install https://luarocks.org/manifests/steved/penlight-1.5.4-1.rockspec
- luarocks install https://luarocks.org/manifests/kong/lua-resty-dns-client-2.2.0-1.rockspec
- luarocks install https://luarocks.org/lua-resty-http-0.13-0.src.rock
- luarocks install https://luarocks.org/manifests/luarocks/luasocket-3.0rc1-2.rockspec

#### 数据表导入MySQL

- 在MySQL中创建数据库,名为orange
- 将与当前代码版本配套的SQL脚本(如install/orange-v0.6.4.sql)导入到orange库中
- 将与当前代码版本配套的SQL脚本(如install/orange-v0.7.0.sql)导入到orange库中

#### 修改配置文件

Orange有**两个**配置文件,一个是`conf/orange.conf`,用于配置插件、存储方式和内部集成的默认Dashboard,另一个是`conf/nginx.conf`用于配置Nginx(OpenResty).
Orange有**两个**配置文件,一个是`conf/orange.conf`,用于配置插件、存储方式和内部集成的默认Dashboard,另一个是`conf/nginx.conf`用于配置Nginx.

orange.conf的配置如下,请按需修改:

Expand All @@ -41,16 +45,7 @@ orange.conf的配置如下,请按需修改:
"plugins": [ //可用的插件列表,若不需要可从中删除,系统将自动加载这些插件的开放API并在7777端口暴露
"stat",
"monitor",
"redirect",
"rewrite",
"rate_limiting",
"property_rate_limiting",
"basic_auth",
"key_auth",
"signature_auth",
"waf",
"divide",
"kvstore"
".."
],

"store": "mysql",//目前仅支持mysql存储
Expand All @@ -67,8 +62,7 @@ orange.conf的配置如下,请按需修改:
"pool_config": {
"max_idle_timeout": 10000,
"pool_size": 3
},
"desc": "mysql configuration"
}
},

"dashboard": {//默认的Dashboard配置.
Expand Down Expand Up @@ -101,9 +95,14 @@ conf/nginx.conf里是一些nginx相关配置,请自行检查并按照实际需

#### 安装

如果使用的是v0.5.0以前的版本则无需安装, 只要将Orange下载下来放到合适的位置即可。
1) 使用方式一

无需安装, 只要将Orange下载下来, 根据需要修改一下`orange.conf`和`nginx.conf`配置,然后使用`start.sh`脚本即可启动。
默认提供的nginx.conf和start.sh都是最简单的配置,只是给用户一个默认的配置参考,用户应该根据实际生产要求自行添加或更改其中的配置以满足需要。

如果使用的是v0.5.0及以上的版本, 可以通过`make install`将Orange安装到系统中。 执行此命令后, 以下两部分将被安装:
2) 使用方式二

可以通过`make install`将Orange安装到系统中(默认安装到/usr/local/orange)。 执行此命令后, 以下两部分将被安装:

```
/usr/local/orange #orange运行时需要的文件
Expand All @@ -112,9 +111,9 @@ conf/nginx.conf里是一些nginx相关配置,请自行检查并按照实际需

#### 启动

在v0.5.0以下版本中, 一个简单的shell脚本用来启动/重启orange, 执行`sh start.sh`即可。可以按需要仿照start.sh编写运维脚本, 本质上就是启动/关闭Nginx。
若采用方式一安装,则执行`sh start.sh`即可启动。可以按需要仿照start.sh编写运维脚本, 本质上就是启动/关闭Nginx。

除此之外, 从v0.5.0开始, 如果执行过`make install`将Orange安装到系统后, 还可以通过`orange`命令来管理, 执行`orange help`查看有哪些命令可以使用:
若采用方式二`make install`安装,则可以通过命令行工具`orange`来管理, 执行`orange help`查看有哪些命令可以使用:

```
Usage: orange COMMAND [OPTIONS]
Expand All @@ -130,13 +129,11 @@ version Show the version of Orange
help Show help tips
```


Orange启动成功后, dashboard和API server也随之启动:

- 内置的Dashboard可通过`http://localhost:9999`访问
- API Server默认在`7777`端口监听,如不需要API Server可删除nginx.conf里对应的配置


### 文档

- 项目文档: [官网](http://orange.sumory.com/docs)
Expand All @@ -154,11 +151,16 @@ Orange启动成功后, dashboard和API server也随之启动:
- [@spacewander](https://github.com/spacewander)
- [@noname007](https://github.com/noname007)
- [@itchenyi](https://github.com/itchenyi)
- [@Near-Zhang](https://github.com/Near-Zhang)
- [@khlipeng](https://github.com/khlipeng)
- [@wujunze](https://github.com/wujunze)



### See also

Orange的插件设计参考自[Kong](https://github.com/Mashape/kong).

### License

[MIT](./LICENSE)
[MIT](./LICENSE) License
131 changes: 131 additions & 0 deletions bin/cmds/register.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
local logger = require("bin.utils.logger")
local http = require("resty.http")
local io = require("orange.utils.io")
local json = require("orange.utils.json")

local _M = {}


_M.help = [[
Usage: orange register

Register current node to cluster

Examples:
orange register
]]


local function base64_encode(source_str)
local b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
local s64 = ''
local str = source_str

while #str > 0 do
local bytes_num = 0
local buf = 0

for byte_cnt = 1, 3 do
buf = (buf * 256)
if #str > 0 then
buf = buf + string.byte(str, 1, 1)
str = string.sub(str, 2)
bytes_num = bytes_num + 1
end
end

for group_cnt = 1, (bytes_num + 1) do
local b64char = math.fmod(math.floor(buf / 262144), 64) + 1
s64 = s64 .. string.sub(b64chars, b64char, b64char)
buf = buf * 64
end

for fill_cnt = 1, (3 - bytes_num) do
s64 = s64 .. '='
end
end

return s64
end

function _M.execute(origin_args)

local err

-- format and parse args
local args = {
orange_conf = origin_args.orange_conf,
prefix = origin_args.prefix
}
for i, v in pairs(origin_args) do
if i == "o" and not args.orange_conf then args.orange_conf = v end
if i == "p" and not args.prefix then args.prefix = v end
end

-- use default args if not exist
-- if not args.prefix then args.prefix = command_util.pwd() end
if not args.prefix then args.prefix = "/usr/local/orange" end
if not args.orange_conf then args.orange_conf = args.prefix .. "/conf/orange.conf" end

if args then
logger:info("args:")
for i, v in pairs(args) do
logger:info("\t%s:%s", i, v)
end
logger:info("args end.")
end

xpcall(function()

-- 读取 orange 配置文件
local orange_conf_text = io.read_file(args.orange_conf)
local orange_conf = json.decode(orange_conf_text)

if #orange_conf.api.credentials[1] ~= 0 then
logger:error("not configure api username and password")
return
end

local credential = orange_conf.api.credentials[1]

local httpc = http.new()

-- 设置超时时间 200 ms
httpc:set_timeout(200)

local url = "http://127.0.0.1:7777"
local authorization = base64_encode(string.format("%s:%s", credential.username, credential.password))
local path = '/node/register'

local resp, err = httpc:request_uri(url, {
method = "POST",
path = path,
headers = {
["Authorization"] = authorization
}
})

httpc:close()

if not err then
if resp.status == 200 then
logger:success("Orange register to cluster.")
else
logger:error(resp.body)
end
else
logger:error(err)
end

end, function(e)
logger:error("Could not register Orange, error: %s", e)
err = e
end)

if err then
error(err)
end
end


return _M
1 change: 1 addition & 0 deletions bin/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local cmds = {
reload = "Reload the config of Orange",
store = "Init/Update/Backup Orange store",
version = "Show the version of Orange",
register = "Register the node",
help = "Show help tips"
}

Expand Down
4 changes: 3 additions & 1 deletion conf/orange.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
"property_rate_limiting",
"basic_auth",
"key_auth",
"hmac_auth",
"signature_auth",
"waf",
"divide",
"kvstore"
"kvstore",
"balancer"
],
"store": "mysql",
"store_mysql": {
Expand Down
Loading