Install and Secure KONG

, , Leave a comment

Install Casandra database

docker run -d --name kong-database -p 9042:9042 cassandra:3

Install Kong

docker run -d --name kong --link kong-database:kong-database -e
"KONG_DATABASE=cassandra" -e
"KONG_CASSANDRA_CONTACT_POINTS=kong-database" -e
"KONG_PG_HOST=kong-database" -p 8000:8000 -p 8443:8443 -p 8001:8001 -p
7946:7946 -p 7946:7946/udp kong:latest

Add a redirect

curl -i -X POST --url http://localhost:8001/apis/ --data
'name=example-api' --data 'hosts=t14.erickkendall.com' --data
'upstream_url=http://httpbin.org'

Add plugin to enforce security

curl -X POST http://127.0.0.1:8001/apis/example-api/plugins --data "name=basic-auth" --data "config.hide_credentials=true"

Add user

curl -d "username=erick" http://127.0.0.1:8001/consumers

Give user a password

curl -X POST http://127.0.0.1:8001/consumers/erick/basic-auth --data "username=erick" --data "password=passwd"

Encode username and password to Base64

https://www.base64encode.org/

Test

curl http://t14.erickkendall.com:8000 -H 'Authorization: Basic ZXJpY2s6cGFzc3dk'

 

Leave a Reply