我的docker-compose.yml
for key,value in your_json.items():
if isinstance(value, dict):
your_json[key]={}
我的Docker容器
version: '2.1'
volumes:
kong_data: {}
networks:
kong-net:
services:
kong-migrations:
image: "${KONG_DOCKER_TAG:-kong:latest}"
command: kong migrations bootstrap
depends_on:
db:
condition: service_healthy
environment:
KONG_DATABASE: postgres
KONG_PG_DATABASE: ${KONG_PG_DATABASE:-kong}
KONG_PG_HOST: db
KONG_PG_PASSWORD: ${KONG_PG_PASSWORD:-kong}
KONG_PG_USER: ${KONG_PG_USER:-kong}
links:
- db:db
networks:
- kong-net
restart: on-failure
kong:
image: "${KONG_DOCKER_TAG:-kong:latest}"
user: "${KONG_USER:-root}"
depends_on:
db:
condition: service_healthy
environment:
KONG_ADMIN_ACCESS_LOG: /dev/stdout
KONG_ADMIN_ERROR_LOG: /dev/stderr
KONG_ADMIN_LISTEN: '0.0.0.0:8001'
KONG_CASSANDRA_CONTACT_POINTS: db
KONG_DATABASE: postgres
KONG_PG_DATABASE: ${KONG_PG_DATABASE:-kong}
KONG_PG_HOST: db
KONG_PG_PASSWORD: ${KONG_PG_PASSWORD:-kong}
KONG_PG_USER: ${KONG_PG_USER:-kong}
KONG_PROXY_ACCESS_LOG: /dev/stdout
KONG_PROXY_ERROR_LOG: /dev/stderr
networks:
- kong-net
ports:
- "8000:8000/tcp"
- "8001:8001/tcp"
- "8443:8443/tcp"
- "8444:8444/tcp"
restart: on-failure
db:
image: postgres:9.5
environment:
POSTGRES_DB: ${KONG_PG_DATABASE:-kong}
POSTGRES_PASSWORD: ${KONG_PG_PASSWORD:-kong}
POSTGRES_USER: ${KONG_PG_USER:-kong}
healthcheck:
test: ["CMD", "pg_isready", "-U", "${KONG_PG_USER:-kong}"]
interval: 30s
timeout: 30s
retries: 3
restart: on-failure
stdin_open: true
tty: true
networks:
- kong-net
volumes:
- kong_data:/var/lib/postgresql/data
go-server:
image: gobuild
networks:
- kong-net
restart: on-failure
我正在尝试向Kong管理员发出POST请求 API,该API在端口8001上运行。但失败。
docker ps --format '{{.Names}}'
chapter11_go-server_1
chapter11_kong_1
chapter11_db_1
输出
{
"name": "myapi",
"hosts": "server1",
"": "http://chapter11_go-server_1:3000",
"uris":["/api/v1"],
"strip_uri": true,
"preserve_host": false
}
如何确定我的POST请求出了什么问题?
什么是上游网址?
答案 0 :(得分:1)
根据Kong 1.0.0 changelog:
API实体和相关概念(例如/ apis端点)已删除(自2018年3月的0.13.0起不推荐使用)。请改用“路线和服务”。
因为Kong 1.0 /apis
端点不再可用。因此,您收到404未找到响应。
要将API添加到Kong,您必须使用/services
和/routes
。本教程说明了如何执行此操作:Configuring a Service