-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
289 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
# v0.5.0 | ||
|
||
新特性(Features) | ||
|
||
* 支持配置nginx日志(access_log) | ||
|
||
优化 | ||
|
||
* 健康检查接口:检查nginx配置是否正确 | ||
|
||
# v0.4.0 | ||
|
||
新特性(Features) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package conf | ||
|
||
var ( | ||
Version = "v0.4.0" | ||
Version = "v0.5.0" | ||
NgFileExtension = ".conf" | ||
EtcdSubPathL4 = "/l4" | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# 健康检查 | ||
|
||
```shell | ||
curl http://127.0.0.1:1216/v1/health | ||
``` | ||
|
||
# 鉴权 | ||
|
||
```shell | ||
# 获取Token | ||
token=$(curl -s -XPOST http://127.0.0.1:1216/v1/login -d "{\"username\":\"admin\",\"password\":\"admin\"}" -H "Content-Type: application/json" | jq -r .data) | ||
echo ${token} | ||
# 访问需要鉴权的接口 | ||
curl -H "Authorization: ${token}" http://127.0.0.1:1216/xxx | ||
``` | ||
|
||
# Nginx相关API | ||
|
||
```shell | ||
# 删除配置 | ||
curl -XDELETE -H "Authorization: ${token}" http://127.0.0.1:1216/v1/admin/nginx/delete?listen=30001 | ||
# 禁用指定端口的配置(启用为on,禁用为off) | ||
curl -XPOST -H "Authorization: ${token}" http://127.0.0.1:1216/v1/admin/nginx/switch -d "listen=30001&switch=off" | ||
# 获取指定端口的配置 | ||
curl -s -H "Authorization: ${token}" http://127.0.0.1:1216/v1/admin/nginx/get?listen=30001 | ||
# 获取所有配置 | ||
curl -H "Authorization: ${token}" http://127.0.0.1:1216/v1/admin/nginx/getAll | ||
# 新增L4配置 | ||
curl -i -H "Content-Type: application/json" -XPOST -H "Authorization: ${token}" http://127.0.0.1:1216/v1/admin/nginx/add -d ' | ||
{ | ||
"listen":30001, | ||
"upstream":{ | ||
"hosts":[ | ||
{ | ||
"ip":"1.1.1.1", | ||
"port":53 | ||
} | ||
] | ||
} | ||
}' | ||
# 更新L4配置 | ||
curl -i -H "Content-Type: application/json" -XPOST -H "Authorization: ${token}" http://127.0.0.1:1216/v1/admin/nginx/set -d ' | ||
{ | ||
"listen":30001, | ||
"upstream":{ | ||
"hosts":[ | ||
{ | ||
"ip":"1.1.1.1", | ||
"port":53 | ||
} | ||
] | ||
} | ||
}' | ||
``` | ||
|
||
# 所有支持的参数 | ||
|
||
```shell | ||
curl -i -H "Content-Type: application/json" -XPOST -H "Authorization: ${token}" http://127.0.0.1:1216/v1/admin/nginx/set -d ' | ||
{ | ||
"disable": false, | ||
"listen": 30001, | ||
"comments": ["我是注释","I am the comment."], | ||
"includeFiles": ["/etc/nginx/my.conf"], | ||
"proxyUploadRate": "10M", | ||
"proxyDownloadRate": "20M", | ||
"proxyConnectTimeout": "10s", | ||
"proxyTimeout": "10m", | ||
"log": { // 默认值:继承全局配置 | ||
"mod": "local", // off:不打印日志;local:单独打印日志;global/其他:继承全局配置。 | ||
"path": "/var/log/nginx/test.stream.log", | ||
"formatName": "my_log_format", | ||
"buffer": "5k", | ||
"flush": "5s" | ||
}, | ||
"upstream":{ | ||
"hosts":[ | ||
{ | ||
"ip": "1.1.1.1", | ||
"port": 53, | ||
"isBackup": false, | ||
"weight": 100, | ||
"maxFails": 10, | ||
"failTimeoutSecond":2 | ||
} | ||
], | ||
"isHash": true, | ||
"hashField": "test_field", | ||
"interval": 10, | ||
"rise": 2, | ||
"fall": 2, | ||
"timeout": 1000 | ||
}, | ||
"whiteList": [ | ||
{ | ||
"type": "allow", | ||
"target": "1.1.1.1" | ||
}, | ||
{ | ||
"type": "deny", | ||
"target": "all" | ||
} | ||
] | ||
}' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# 一些测试case | ||
|
||
```shell | ||
# 写入有问题的配置 | ||
etcdctl put /openfly/l4/30001 '{"listen":30001,"upstream":{"hosts":[{"ip":"","port":53}]}}' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
如何优雅退出 | ||
|
||
* 发送term(15号)给openfly进程,可以在INFO日志中查看到退出过程。示例:```kill <pid>`` | ||
|
||
若nginx因配置错误无法启动,如何解决? | ||
|
||
1. 保证nginx本身配置无错误。 | ||
2. 通过openfly接口 修改/删除 错误配置。 | ||
3. 通过etcd 修改/删除 错误配置。 | ||
|
||
添加重复接口会报错吗? | ||
|
||
* 会 | ||
|
||
若配置有问题,会导致线上问题吗? | ||
|
||
* 不会。 | ||
* nginx -t失败后配置不生效。 |