【发布时间】:2022-11-03 02:08:42
【问题描述】:
我正在尝试在 Docker-Compose 中设置 Kong 代理,但有些东西不起作用。我的 Docker-compose 文件如下所示:
version: '3.8'
name: 'App'
networks:
api-network:
name: api-network
driver: bridge
services:
kong:
image: kong:3.0
volumes:
- ./App/kong/kong.yml:/usr/local/kong/declarative/kong.yml
container_name: kong
environment:
KONG_DATABASE: 'off'
KONG_PROXY_ACCESS_LOG: '/dev/stdout'
KONG_ADMIN_ACCESS_LOG: '/dev/stdout'
KONG_PROXY_ERROR_LOG: '/dev/stderr'
KONG_ADMIN_ERROR_LOG: '/dev/stderr'
KONG_ADMIN_LISTEN: "0.0.0.0:8001, 0.0.0.0:8444 ssl"
KONG_DECALATIVE_CONFIG: "/usr/local/kong/declarative/kong.yml"
command: "kong start"
networks:
- api-network
ports:
- "8000:8000"
- "8443:8443"
- "127.0.0.1:8001:8001"
- "127.0.0.1:8444:8444"
building_service:
container_name: building_service
build: ./App/building_service
restart: always
command: uvicorn app.main:app --reload --host 0.0.0.0 --port 80
ports:
- 8004:80
expose:
- 80
networks:
- api-network
volumes:
- ./App/building_service:/usr/src/building_service/
我的 kong.yml 文件:
_format_version: "3.0"
_transform: true
services:
- name: building_service
url: http://building_service/building
routes:
- name: building_service_route
paths:
- /building
当我检查服务http://localhost:8001/services 时,我收到消息:
{"next":null,"data":[]}
当我检查配置 http://localhost:8001/config 时,我收到消息:
{"config":"_format_version: '3.0'\n_transform: false\n"}
最后,当我尝试为我的 building_service http://localhost:8000/building/docs 或只是构建 http://localhost:8000/building 打开文档(fastAPI)时,我得到:
{"message":"no Route matched with those values"}
【问题讨论】:
标签: kong