Kong is actually a ngnix, by adding plug-ins to the request to do the pre-processing, mainly authorized one. installation of Kong services; https://konghq.com/install/offers a variety of ways to install, It is recommended to install using Docker: (the installation of the CentOS tar package is recommended using the node. JS installation Kong-dashboard) The latest version of Kong does not support Kong-dashboard, so the version I use is v0.13.1 Docker Installation of Kong services, https://docs.konghq.com/install/docker/
Create a Docker network
You'll need to create a custom network to allow the containers to discover and communicate with each other. In this example kong-net
are the network name, you can use any name.
$ docker network create kong-net
-
Start your database
If you wish to use a Cassandra container:
$ Docker run-d--name kong-database --net Work=kong-net -P 9042:9042 cassandra:3
If wish to use a PostgreSQL container:
$ Docker run-d--name kong-database --network=kong-net -P 5432:5432 -e "Postgres_user=kong"
-e
"Postgres_db=kong" postgres:9.6
-
Prepare your database
Run The migrations with an ephemeral Kong container:
$ Docker run--rm --network =kong-net -e "kong_database=postgres" -e "kong_pg_host=kong-database" -e "kong_cassandra_contact_points= Kong-database " Kong:latest Kong migrations up
In the above example, both Cassandra and PostgreSQL is configured, but we should up Date the kong_database
environment variable with either Cassandra
or postgres
.
Note : Migrations should never is run concurrently; only one Kong node should be performing migrations At a time.
Start Kong
When the migrations has run and your database is ready, start a Kong container that would connect to your database contain Er, just like the ephemeral migrations container:
$ docker run-d--name Kong--network=kong-net -e "kong_database=postgres" -e "kong_pg_host=kong-database" -e "kong_cassandra_contact_points= Kong-database "-e " kong_proxy_access_log=/dev/stdout "-e "kong_admin_access_log=/dev/stdout" -e "kong_proxy_error_log=/dev/ stderr "-e " Kong_admin_error_log=/dev/stderr "-E "kong_admin_listen=0.0.0.0:8001, 0.0.0.0:8444 SSL" -P 8000:8000 -P 8443:8443 -P 8001:8001 -P 8444:8444 Kong:0.13.1-centos
Use Kong
Kong is running:
$ curl -i http://localhost:8001/
Can get to a big create JSON data on behalf of the service started successfully two installation Kong-dashboardHttps://github.com/PGBI/kong-dashboardUsing Docker
# start Kong dashboarddocker run--rm-p 8080:8080 pgbi/kong-dashboard start--kong-url http://kong:8001# start Ko Ng Dashboard on a custom portdocker run--rm-p [port]:8080 pgbi/kong-dashboard start--kong-url http://kong:8001# Sta RT Kong Dashboard with basic authhttp://kong:8001 \--basic-auth user1=password1 user2=password2# See full list of start Optionsdocker run--rm-p 8080:8080 pgbi/kong-dashboard start--help
Note If the service of Kong is also Docker, Kong-url address should be the intranet addresses, localhost is unable to connect if the use of the intranet address can not connect, try the following code:
- Create Bridge Network
docker network create my-net
- Add Kong Container to it
docker network connect my-net kong
- Provide network info when you run Kong-dashboard
docker run --rm --network my-net -p 8080:8080 pgbi/kong-dashboard start --kong-url http://kong:8001
Visit http://your-address:8001
Linux Installation Kong Gateway