[Kong series three] Kong simple use

kong start After successful startup

1.The role of each port

1).port:8000 The client callsapi the port, and the gateway opens the port to the outside world. For example: create a new api, visitpath= /test, then visit http://10.110.2.3:8000/test

2).port:8001 kong admin apiManagement port, you can use this port to pairapiconsumer、< /span>plugin to manage, for example: view the name calledtest thisapiconfiguration information, Visit http://10.110.2.3:8001/apis/test,View allapiinformation, visit http://10.110.2.3 :8001/apis

3). KONGManage the platform, visit http://10.110.2.3:8888/#/< /span> This port must be installed kong dashboard. Through this port, you can use graphical interface managementapi,consumer,plugin Wait.

2 .Simple usage example

1).View existingapis

$ curl http://127.0.0.1:8001/apis

< /p>

2).Add oneapi

$ curl -i -X ​​POST –url http:/ /127.0.0.1:8001/apis/ –data’name=person2api’ –data’methods=GET’ –data’uris=/testUser’ –data’hosts=127.0.0.1′ –data’upstream_url= http://10.110.2.54:8040/metrics’

HTTP/1.1 201 Created

Date: Thu, 27 Jul 2017 11: 24:09 GMT

Content-Type: application/json; charset=utf-8

Transfer-Encoding: chunked

Connection: keep-alive

Access-Control-Allow-Origin: *

Server: kong/ 0.10.3

{“methods”:[“GET”],”http_if_terminated”:true,”id” :”dffb6cbb-1a0d-4a1f-aff8-72b7a2aad586″,”retrie s”:5,”preserve_host”:false,”created_at”:1501154650000,”upstream_connect_timeout”:60000,”upstream_url”:”http://10.110.2.54:8040/metrics”,”upstream_read_timeout”:60000, “upstream_send_timeout”:60000,”https_only”:false,”strip_uri”:true,”uris”:[“/testUser”],”name”:”person2api”,”hosts”:[“127.0.0.1”]}

3).Visit thisapi

$ curl http://127.0.0.1:8000/testUser

For detailedadmin api operation, please refer to: https://getkong.org/docs/ 0.10.x/admin-api/

Leave a Comment

Your email address will not be published.