KONG 基本使用

参考:https://docs.konghq.com/2.0.x/getting-started/introduction/

参考:开源API网关系统(Kong教程)入门到精通

参考:Kong API Gateway 配置文件详解

 

kong help

kong start --conf /path/to/kong.conf

kong restart

kong check <path/to/kong.conf>

kong stop

kong reload


ulimit -n 4096

 

curl -i http://localhost:8001/

curl -i http://localhost:8000/
1.Add your Service using the Admin API

curl -i -X POST --url http://localhost:8001/services/ --data 'name=example-service' 
--data 'url=http://192.168.1.7:8083/test/data/building/'


2.Add a Route for the Service
curl -i -X POST --url http://localhost:8001/services/example-service/routes 
--data 'hosts[]=192.168.1.7:8083'


3.Forward your requests through Kong
curl -i -X GET --url http://localhost:8000/ --header 'Host: 192.168.1.7:8083'
4.Configure the key-auth plugin
curl -i -X POST --url http://localhost:8001/services/example-service/plugins/ 
--data 'name=key-auth'


5.Verify that the plugin is properly configured
curl -i -X GET --url http://localhost:8000/ --header 'Host: 192.168.1.7:8083'

curl -i -X POST --url http://localhost:8001/services/water_landcover/plugins --data 'name=key-auth'

curl -i -X POST --url http://localhost:8001/consumers --data 'username=agan' --data 'custom_id=001'

curl -i -X POST --url http://localhost:8001/consumers/agan/key-auth --data 'key=20200402'

# 查找所有KEY
curl -X GET http://kong:8001/key-auths

# 查找KEY的使用者
curl -X GET http://kong:8001/key-auths/{key or id}/consumer

curl -i -X DELETE --url http://localhost:8001/routes/8c165093-4112-4330-8092

curl -i -X DELETE --url http://localhost:8001/services/building

 

"sprite": "http://192.168.1.8:80/statics/sprite/sprite"
curl -i -X POST --url http://localhost:8001/services/ --data 'name=sprite' 
--data 'url=http://192.168.1.8:80/statics/sprite/'

curl -i -X POST --url http://localhost:8001/services/sprite/routes --data 'protocols[]=http' 
--data 'paths[]=/statics/sprite/' --data 'service.name=sprite'

"glyphs": "http://192.168.1.8:80/statics/fonts/{fontstack}/{range}.pbf",
curl -i -X POST --url http://localhost:8001/services/ 
--data 'name=glyphs' --data 'url=http://192.168.1.8:80/statics/fonts/'

curl -i -X POST --url http://localhost:8001/services/glyphs/routes 
--data 'protocols[]=http' --data 'paths[]=/statics/fonts/' 
--data 'service.name=glyphs'

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值