Quick Start to Kong API Management

Hi all, managing web APIs has always been a problem. There are quite a few advanced API Management services, such as MS Azure, AWS, CA-like capabilities, but you have to pay a certain fee to use these tools. You can manage your web APIs for free with these tools: kong, tyk, etc. These tools can be used as an alternative solution.

In this article, I will tell you how to manage web API with kong.

  • Operating System: CentOS 7.3
  • DB Server: PostgreSQL 9.6

You can download KONg from this address: https://getkong.org/install/centos

Run below commands on CentOS.

[root@localhost ~]# yum install epel-release
[root@localhost ~]# yum install kong

Kong supports Cassandra and PostgreSQL 9.4+ as DB.
We need to create DB for Kong:

CREATE USER kong; 
CREATE DATABASE kong OWNER kong;

After creating the DB, we write the access information into kong.conf.

############### PGSQL config start #################
database = postgres
pg_host = xxx.xxx.xxx.xxx
pg_port = 5432
pg_user = yyyy

pg_password = zzzzz

pg_database = kong

############### PGSQL config end #################

We can now run the application.

[root@localhost ~]# kong start
# Kong is running

For access: curl http://kong-ip-address:8001

Once the kong setup is finished, you can use the kong-dashboard to manage your web APIs over the web.

For kong-dashboard setup: https://github.com/PGBI/kong-dashboard

Requirements: nodejs & npm

[root@localhost ~]# npm install -g kong-dashboard
[root@localhost ~]# kong-dashboard start

Go to http://kong-ip-address:8080/#/config config in your web browser.

kong

Now that you are ready to manage your API with Kong, we add APIs from the APIs tab.

You can now call your API via Kong. http://kong-ipaddress:port/api/path

You can add a basic authentication without modifying the code for your API, which you started to manage over Kong.

From the Consumer tab, we add a record for testing and enable the basic authentication plugin in the plugin tab.

The API you are calling from http://kong-ipaddress:port/api/path  will now need to be accessed with user/password. You can access it with the user/password you have added to Consumer.

Thanks.
-Ahmet Fikri Ay

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.