Git Product home page Git Product logo

apigateway's Introduction

Kong API Gateway

This repo has some of my poc's on Kong on how to set it up and how to use plugins.

Install Cassandra

# kong needs Postgres or Cassandra as datastore. Install if not present

$ docker run -d --name kong-database \
              -p 9042:9042 \
              cassandra:2.2

Install and start Kong

# Link cassandra and start 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

# osx install

download the .pkg from https://getkong.org/install/osx/

# before starting open the config at /etc/kong/kong.conf and check the datastore config
# if file not present make a copy of default file and rename to kong.conf

# start kong
$ kong start -c /etc/kong/kong.conf --vv

# check status
$ curl 127.0.0.1:8001

Add your API

# start apache-cxf-jax-ws-demo (SOAP) and producer (REST) projects
# i have httpie installed, not a must curl will do
# i have the admin api running at 8003 instead of 8001
# 2 methods to add api

# Method1: Request Host
$ http POST localhost:8003/apis name=resttest1 upstream_url=http://localhost:8079/counter request_host=resttest1.com

# test
$ http http://localhost:8002 Host:resttest1.com

# Method2: Request Path
$ http POST localhost:8003/apis name=resttest2 upstream_url=http://localhost:8079 request_path=/counter

# test
$ http get http://localhost:8002/counter

# add SOAP service, for test use soap ui
$ http POST localhost:8003/apis name=soaptest1 upstream_url=http://localhost:8080 request_path=/HelloWorld

# get list of api's
$ http GET localhost:8003/apis

# List of commands are available at getkong.org

Add key Auth

$ http POST http://localhost:8003/apis/soaptest1/plugins name=key-auth
$ http POST http://localhost:8003/apis/resttest2/plugins name=key-auth

Add Consumers

$ http POST http://localhost:8003/consumers/ username=soapuser1 custom_id=1
$ curl -X POST http://localhost:8003/consumers/soapuser1/key-auth -d ''

$ http POST http://localhost:8003/consumers/ username=restuser1 custom_id=2
$ curl -X POST http://localhost:8003/consumers/restuser1/key-auth -d ''

# post with apikey header
$ http get http://localhost:8002/counter apikey:xxxx

ACL

# Restrict user access based on groups

$ http POST http://localhost:8003/apis/soaptest1/plugins name=acl config.whitelist=soapgroup
$ http POST http://localhost:8003/consumers/soapuser1/acls  group=soapgroup

$ http POST http://localhost:8003/apis/resttest2/plugins name=acl config.whitelist=restgroup
$ http POST http://localhost:8003/consumers/restuser1/acls  group=restgroup

# through soapuser1 key u cannot access the rest service

Dashboard

# community project distributed over NPM

# Install Kong Dashboard
$ npm install -g kong-dashboard

# To start Kong Dashboard on a custom port
$ kong-dashboard start -p [port]

# available in the below url
http://localhost:port/

apigateway's People

Contributors

itsmurugappan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.