Linux Installation Kong Gateway

Source: Internet
Author: User
Tags auth cassandra postgresql centos docker run

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/
  1. 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
  2. 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   
                  
  3. 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.

  4. 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            
  5. 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:
    1. Create Bridge Network
      docker network create my-net
    2. Add Kong Container to it
      docker network connect my-net kong
    3. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.