Kong Mirror: hub.docker.com/_/kong
The password of PG is not set in the user installation manual given on the official website, resulting in the following problems
Nginx: [error] init_by_lua error: / usr/local/share/lua / 5.1 / kong/init. Lua: 277: [PostgreSQL error] failed to >retrieve server_version_num: connection refused stack traceback:[C]: In the function ‘assert’/usr/local/share/lua / 5.1 / kong/init. Lua: 277: in the function ‘init’ init_by_lua: 3: in the main chunk
Docker-compose: github.com/Kong/docke….
Use the Docker installation
Kong uses Either PostgresQL or Cassandra to store data. Here, we’ll use PG
Docker run -d --name kong-database \ -p 5432:5432 \ -e "POSTGRES_USER=kong" \ -e "POSTGRES_DB=kong" \ -e "POSTGRES_PASSWORD=your_pg_password" \ postgres:9.6 # kong Data migration to PG docker run --rm \ --link kong-database:kong-database -e "KONG_DATABASE=postgres" \ -e "KONG_PG_HOST=kong-database" \ -e -e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \ kong "kong_cassandra_points =kong-database" \ kong Kong migrations bootstrap # Create the Kong container docker run -d --name kong \ --link kong-database:kong-database \ -e "KONG_DATABASE=postgres" \ -e "KONG_PG_HOST=kong-database" \ -e "KONG_PG_PASSWORD=your_pg_password" \ -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 \ # HTTP proxy port -p 8443:8443 \ # HTTPS proxy port -p 8001:8001 \ # HTTP management interface -p 8444:8444 \ # Docker logs kong # curl-x GET docker logs kong # curl-x GET docker logs Kong # curl-x GET http://192.168.20.6:8001Copy the code
Since the Kong service is in a container, set
KONG_ADMIN_LISTEN
For global listening only access through host IP proxy, the host needs to make the corresponding mapping port access restrictions, such as local/Intranet access, and should not be accessible to the external network, otherwise anyone can change your Api gateway policy.
Customize the Kong configuration file
The configuration file path of the Kong Docker image is /etc/kong/kong.conf To customize the configuration file, mount it yourself. Kong Configuration Item Manual: docs.konghq.com/1.0.x…
. -v /opt/kong/kong.conf:/etc/kong/kong.conf ...Copy the code
Install the Kong monitoring plugin Konga
docker run -d -p 1337:1337 \ --network kong-net \ --name konga \ -e "NODE_ENV=production" \ -e "DB_ADAPTER=postgres" \ - e DB_URI = postgresql: / / "kong: [email protected]:5432 / kong" \ pantsel/kongaCopy the code
Take a look at the Kong integration Jwt plugin: www.cnkirito.moe/kong… Kong service gateway API:www.jianshu.com/p/ef6…