kong__0">kong 安装
docker network create kong-net
安装postgres 9.6 本版很重要 高版本 安装konga 初始化会有问题
docker run -d --name kong-database \--network=kong-net \-p 5432:5432 \-e "POSTGRES_USER=kong" \-e "POSTGRES_DB=kong" \-e "POSTGRES_PASSWORD=kong" \postgres:9.6
初始化数据
docker run --rm --network=kong-net \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_PG_PASSWORD=kong" \
-e "KONG_PASSWORD=test" \
kong/kong-gateway:3.4.3.7 kong migrations bootstrap
docker run -d --name kong-gateway \
--network=kong-net \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_PG_USER=kong" \
-e "KONG_PG_PASSWORD=kong" \
-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" \
-e "KONG_ADMIN_GUI_URL=http://localhost:8002" \
-e KONG_LICENSE_DATA \
-p 8000:8000 \
-p 8443:8443 \
-p 8001:8001 \
-p 8444:8444 \
-p 8002:8002 \
-p 8445:8445 \
-p 8003:8003 \
-p 8004:8004 \
kong/kong-gateway:3.4.3.7
curl -i http://192.168.21.125:8001 curl -i -X GET --url http://192.168.21.125:8001/serviceshttp://192.168.21.125:8002
kong api 初始化写数据
curl -X POST http://192.168.21.82:8001/upstreams --data name=main-services-en
curl -X POST http://192.168.21.82:8001/upstreams/main-services-en/targets --data target='main-services-en.test5.svc.cluster.local:80' --data weight=50
curl -i -s -X POST http://192.168.21.82:8001/services --data name=main-services-en --data url='http://main-services-en'
curl -i -X POST http://192.168.21.82:8001/services/main-services-en/routes --data 'hosts[1]=videoapi-hk.cdreader.com' --data 'paths[1]=/' --data 'paths[2]=/video' --data 'paths[3]=/pay' --data 'paths[4]=/account' --data 'paths[5]=/message' --data name=main-services-en --data path_handling=v0
curl -X POST http://192.168.21.82:8001/routes/main-services-en/plugins --data "name=ip-restriction" --data "config.deny=192.168.21.136" --data "config.status=403" --data "config.message=no permission"
docker 命令
docker logs 21e9ee2b9542docker ps -a
docker stop f78823355d48
docker start f78823355d48docker images
docker rmi 113950dafdbb
konga__88">konga 安装
docker run --rm --network=kong-net pantsel/konga -c prepare -a postgres -u postgresql://kong:kong@kong-database:5432/konga
docker run -p 1337:1337 \--network kong-net \--name konga \-e "NODE_ENV=production" \-e "DB_ADAPTER=postgres" \-e "DB_URI=postgresql://kong:kong@kong-database:5432/konga" \pantsel/konga
http://192.168.21.125:1337/register
admin/1234567
kong api 示例
curl -X POST http://192.168.21.125:8001/upstreams --data name=main-services-en
curl -X POST http://192.168.21.125:8001/upstreams/main-services-en/targets --data target='main-services-en.test5.svc.cluster.local:80' --data weight=50
curl -i -s -X POST http://192.168.21.125:8001/services --data name=main-services-en --data url='http://main-services-en'
curl -i -X POST http://192.168.21.125:8001/services/main-services-en/routes --data 'hosts[1]=videoapi-hk.cdreader.com' --data 'paths[1]=/' --data 'paths[2]=/video' --data 'paths[3]=/pay' --data 'paths[4]=/account' --data 'paths[5]=/message' --data name=main-services-en --data path_handling=v0 curl -X POST http://192.168.21.125:8001/routes/main-services-en/plugins --data "name=ip-restriction" --data "config.deny=192.168.21.136" --data "config.status=403" --data "config.message=no permission" curl -X POST http://192.168.21.125:8001/upstreams --data name=cdreadercomment-en
curl -X POST http://192.168.21.125:8001/upstreams/cdreadercomment-en/targets --data target='cdreadercomment-en.test6.svc.cluster.local:80' --data weight=50
curl -i -s -X POST http://192.168.21.125:8001/services --data name=cdreadercomment-en --data url='http://cdreadercomment-en'
curl --request POST --url http://192.168.21.125:8001/services/cdreadercomment-en/routes --header 'Content-Type: multipart/form-data' --form-string name=cdreadercomment-en --form-string 'expression=(net.protocol == "http" || net.protocol == "https") && (http.host == "api-test6.changdu.ltd" || http.host == "api.cdreader.com") && (http.path ^= "/") && (http.queries.ActionID ~ "^(124|6660|6661|6662|6663|6664|6665|6666|6667|6668|6669|6700|6701|6704|6705|6706|6707|6708|9026|9084|30001|30002|30003|30004|30005|30006|30008|30009|30010|30013|30014|30015|30016|30017|30018|30019|30020|30021|30022|31001|31002|31003|31004|31005|31006|90266)$")'curl --request POST --url http://192.168.21.125:8001/services/cdreadercomment-en/routes --header 'Content-Type: multipart/form-data' --form-string name=cdreadercomment-en-uri --form-string 'expression=(net.protocol == "http" || net.protocol == "https") && (http.host == "api-test6.changdu.ltd" || http.host == "api.cdreader.com") && (http.path == "/c3/v1/comment/bookcommentlist" || http.path == "/c3/v1/comment/cancelreplysupport" || http.path == "/c3/v1/comment/cancelsupport" || http.path == "/c3/v1/comment/commitbookcomment" || http.path == "/c3/v1/comment/commitcommentreply" || http.path == "/c3/v1/comment/commitreport" || http.path == "/c3/v1/comment/endchapterpush" || http.path == "/c3/v1/comment/getbookdetail" || http.path == "/c3/v1/comment/getcommentreplylist" || http.path == "/c3/v1/comment/replysupport" || http.path == "/c3/v1/comment/support")'curl -X POST http://192.168.21.125:8001/routes/cdreadercomment-en/plugins --data "name=request-transformer" --data "config.add.headers=x-transfer:cdreadercomment-en.test6"