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'

 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章