linux 安裝kong gateway

來源:互聯網
上載者:User

標籤:oca   doc   sql   href   node   name   linu   img   pre   

kong 實際上就是一個ngnix,通過增加外掛程式的方式對請求做前置處理,主要是授權一.安裝kong 服務;https://konghq.com/install/  提供多種方式的安裝,建議使用docker進行安裝:(centos的tar包的安裝方式,建議使用node.js 安裝 kong-dashboard)最新版本的kong不支援kong-dashboard,所以我使用的版本是 v0.13.1 docker 安裝 kong服務,  https://docs.konghq.com/install/docker/
  1. Create a Docker network

    You will need to create a custom network to allow the containers to discover and communicate with each other. In this example kong-net is 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               --network=kong-net               -p 9042:9042               cassandra:3

    If you 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 are configured, but you should update the KONG_DATABASE environment variable with either cassandra or postgres.

    Note: migrations should never be run concurrently; only one Kong node should be performing migrations at a time.

  4. Start Kong

    When the migrations have run and your database is ready, start a Kong container that will connect to your database container, 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/  
 能擷取到一大創json資料代表格服務啟動成功 二安裝kong-dashboard   https://github.com/PGBI/kong-dashboard Using Docker
# Start Kong Dashboarddocker run --rm -p 8080:8080 pgbi/kong-dashboard start --kong-url http://kong:8001# Start Kong Dashboard on a custom portdocker run --rm -p [port]:8080 pgbi/kong-dashboard start --kong-url http://kong:8001# Start Kong Dashboard with basic authdocker run --rm -p 8080:8080 pgbi/kong-dashboard start   --kong-url http://kong:8001 \   --basic-auth user1=password1 user2=password2# See full list of start optionsdocker run --rm -p 8080:8080 pgbi/kong-dashboard start --help
 注意點 如果kong的服務也是docker起的, kong-url的 address 應該為內網地址,localhost是無法串連的 如果使用了內網地址還無法串連,嘗試以下代碼:
  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
訪問 http://your-address:8001  

linux 安裝kong gateway

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.