PermalinkAdd a Service and Route
PermalinkIntroduction
This topic walks through the creation and configuration of a Service and Route using Kong Manager in Kong Enterprise. To do this using the command line, read Kong’s guide to Configuring a Service.
For the purpose of this guide, we’ll create a Service pointing to the Mockbin API. Mockbin is an “echo” type public website that returns requests back to the requester as responses. This visibility is helpful for learning how Kong proxies API requests.
Kong exposes the RESTful Admin API on port :8001
. Kong’s configuration,
including adding Services and Routes, is made via requests on to the
Admin API.
PermalinkPrerequisites
PermalinkStep 1 - Create a New Service
-
Choose the desired Workspace in Kong Manager and navigate to the Services tab under API Gateway.
-
Click the New Service button to open the Create Service dialog. Fill in a Name and a URL for the Service.
For example, set the name totest-service
with the URLhttp://mockbin.org
.
Kong Manager also allows Services to be configured using Protocol, Host, Path, and Port (optional). To configure the Service using this method, click the Add using Protocol, Host, and Path option.
In addition, Kong Manager exposes several Advanced Fields and their default configuration values:Retries: 5
Connect Timeout: 60000
(in ms)Write Timeout: 60000
(in ms)
Read Timeout: 60000
(in ms)
Adjusting these values is optional and can be edited later. -
Create the Service by clicking the Create button.
If successful, you are automatically redirected to the Service’s Overview page.
The Service Overview page displays information and Activity on the Service, as well as any Routes or Plugins that have been connected to the Service.
PermalinkStep 2 - Create a New Route attached to the Service
-
From the Service Overview page accessed in Step 1, click the Create New Route button located in the Routes tab at the bottom of the page.
-
To create a Route you must provide the Service
name
andid
, this will be automatically filled out if the form was accessed via the Service Overview page.
If this field is not automatically filled, the Service Id can be found via the Services Overview page, accessed by clicking on the Services tab on the side navigation and then clicking the clipboard icon next to the desired Service’s Id field. -
The Route will also need a name, and at least one of the following fields: Host, Methods, or Paths
To continue with the Mockbin example, name the Routetest-route
with the Hostexample.com
. Once completed, click Create Route. -
If created successfully, the page will be automatically redirected back to the Service Overview page, and the new Route will now appear under the Routes tab.
PermalinkStep 3 - Test the new Service and Route
Issue the following cURL request to verify that Kong is properly forwarding
requests to the Service. Note that by default Kong handles proxy requests on
port :8000
:
$ curl -i -X GET \
--url http://localhost:8000/ \
--header 'Host: example.com'
A successful response means Kong is now forwarding requests made to http://localhost:8000 to the Service URL configured in Step 1, and is forwarding the response back. Kong knows to do this through the header defined in the above cURL request.