Introducing and installing Kong as the Gateway for System Microservices

Tram Ho

In this article, I will introduce the Kong API Gateway and run the Kong API Gateway on Docker.

Why is Kong?


Kong is an open-source API Gateway and platform, Kong is written in Lua language and built on NGINX. Kong supports many plugins to make microservices easier to implement, such as authentication, rate-limiting, transformation, logging, etc. I can write plugins for Kong by Lua depending on my needs.

Advantages of Kong

Easy scalability

Kong server is stateless, we can add or delete as many nodes as we want, as long as they point to a datastores. Kong Datastore can choose 1 of 2 types of DB

  • Postgres : when it comes to building a centralized, simple, efficient Api Gateway system. By default, Kong will use Postgres as a datastore.
  • Cassandra : Using cassandra when building a distributed gateway api system, high availability, good load, easy scaling. Cassandra will run best on heavily configured servers.

Great performance

In tests performance, Kong is one of the most efficient API Gateway, it can handle a lot of requests / s.

Many plugins

Kong supports a wide range of plugins depending on functions such as authen, logging, traffic control, analytics & monitoring … to help manage and track microservices more effectively and easily instead of just taking care of each routing requests.

How to use jQuery plugins in VueJS


Kong has two versions, Community and Enterprise. The Enterprise edition supports more things like Kong Admin GUI, online support, using Plugins Enterprises and of course it takes money, lots of money is different. However, with the need to use normally, the free version of it is available for use, and we can use Konga to manage and configure Kong with GUI instead of sending requests to Kong Admin (Kong Commnity does not have GUI, only Enterprise version available)


Kong supports a variety of platforms to be installed such as Ubuntu, Centos, Red Hat, Kubernetes, Docker … more specifically, you can go here to download the version that suits you.

Kong on Docker

The installation of Kong has very detailed and detailed instructions on the homepage, we will have to install Kong Server , Kong Datastore , Konga to manage Kong, Database for Konga, quite a lot of things, to make it easier for all I will provide “Instant Kong” on Docker using Docker -compose. All you need is a computer with Docker , Docker docker-compose and internet installed.


Explain the services used in docker-compose file and how to customize it

  • kong-database
    • Overview: Database is used as a datastore for Kong.
    • Details: This service uses Postgre Version 9.6 from docker hub, is used as a datastore for Kong Server.
      • Variant environment:
        • POSTGRES_USER: database user name (default: kong).
        • POSTGRES_DB: database name (default: kong).
        • POSTGRES_PASSWORD: database user password (default: kong).
  • kong
    • Overview: Kong Server.
    • Details: This service uses Kong Comunity Edittion latest Kong Comunity Edittion image from docker hub (linux alpine version)
    • Variant environment:
      • KONG_DATABASE: postgres / cassandra – config database used by Kong, here we use postgres .
      • KONG_PG_HOST: Postgres database address.
      • KONG_PG_PASSWORD: Postgres database user password.
      • KONG_PROXY_LISTEN: The address to which we will send http requests to Kong for processing and routing (default:, on the production environment using
      • KONG_PROXY_LISTEN_SSL: Address to which we will send https requests to Kong for processing and routing (default:, on the production environment using
      • KONG_ADMIN_LISTEN: The address we will use to manage Kong through sending a request or using Konga. – konga
      • Overview: Konga GUI.
      • Detail: This service uses konga image from dockerhub to provide a monitoring and management interface for Kong, instead of a manual request to Kong Admin.
  • kong-migration
    • Overview: Migrate database for Kong can use – konga-prepare
    • Overview db Prepare db to use for Konga

Install Kong

Clone file docker-compose on

Change directory to directory containing docker-compose file

Run docker-compose

We will wait a while for the services to be run, check to see if Kong has been successfully run by sending a request to Kong Admin.

Next we go to Konga (port 1337) to start using Kong using the browser and go to http://localhost:1337 . Konga will ask us to create an Admin account to use

After creating the account and logging in, the first thing we need to do is to connect Konga to Kong Server via Kong Admin by filling in the form, with the Kong admin url being the address of Kong admin, in this case We will have to use the local network address of the device we are using instead of localhost because Konga is running in Docker container. To check the address of the machine, we can use the ifconfig command (with Unix, installed nettools). My device is

After creating the connection, we were able to manage the Kong server from Konga.


In this article, I have introduced a very popular and powerful API Gateway now that is the Kong API Gateway and how to install it to run on Docker. The next article will guide you how to configure and use Kong to manage the system microservices effectively.

Create API server on Node.js with Express and MongoDB (Part 1)
Create API server on Node.js with Express and MongoDB (part 2)
Share the news now

Source : viblo