I was learning how to use Kong API Gateway recently. Although it is a great product and is easy to use, I can't find the right instructions to achieve the features that I needed. for example:
Use https on Kong Admin API
Http to https redirect
Automation of SSL certificate
Deploy Konga which is a Github project of GUI for Kong Admin API
We can still use Admin API locally on the server via curl or Httpie
After a lot of attempts, I settle with using Traefik as reverse proxy to achieve above goals. If you know any correct or better ways of using Kong and Konga, please let me know.
In this article, I am going to use file provider to config Traefik. If you are not sure how to use file provider, please check my previous post. I will list all files and their content on this article as my default configuration does not use file provider.
First thing first, let’s create the necessary files.
These are all the files we need to start Traefik. Please make sure your have change all instance of yourdomain in the config to your own domain and then run docker-compose up -d. We should be able to access the Traefik dashboard at dash.yourdomain once its container is up and running.
####################################### # Konga: GUI of KONG Admin API ####################################### konga: image:pantsel/konga env_file: -kong.env networks: -default -proxy restart:on-failure depends_on: kong-database: condition:service_healthy
networks: proxy: external:true
There are some information I need to mention.
You have a choice to NOT use database for Konga. If you choose not to use a database, you can comment out konga-prepare but you must create a persistent volume to store Konga data.
1 2
volumes: -konga-data:/app/kongadata
However, you will always see below warnings in logs.
1 2 3 4 5
konga_1 | The default `sails-disk` adapter is not designed for use as a production database; konga_1 | (it stores the entire contents of your database in memory) konga_1 | Instead, please use another adapter; e.g. sails-postgresql or sails-mongo. konga_1 | For more info, see: http://sailsjs.org/documentation/concepts/deployment konga_1 | To hide this warning message, enable `sails.config.orm.skipProductionWarnings`.
As I don’t want to see these warnings, I chose to add a database in existing postgresql container and use konga-prepare to prepare the database I need. This is another reason I don’t use Cassandra with Kong.
The use of postgres:9.6-alpine image. Konga does not support the latest postgres version, I found this information from official github issues here.
I put all environment variables that I need in kong.env file.
Once I’ve put contents to these two files, let’s go to ~/kong/ and run docker-compose up -d. It should create postgresql, kong and konga containers automatically for you.
Adding Kong and Konga to Traefik
Once all containers are running, we will use docker inspect <container_id> to get the ip address of Kong and Konga containers. Then we can put these ip address under Services on ~/data/configurations/dynamic.yml.
If you are not too sure how to add ip address to services, please check my post of file provider. I will create a video for this post when I have time.
If you have any questions, please feel free to leave me a comment.