I have set up a docker-compose yaml file to launch Kong Gateway, and to have it point to my backend.
The docker compose file starts up just fine with Kong and my API service. I can verify that kong is up and running as I can query it’s services etc…
The thing is I’m using a yaml configuration file to setup my services and routes:
_format_version: "2.1"
_transform: true
services:
- name: registrations-api-gateway
url: http://127.0.0.1:4556
# # Entities can store tags as metadata
tags:
- example_1
- example_2
- example_3
- example_4
routes:
- name: reg-route
methods:
- POST
paths:
- /registrations
My docker-compose file looks like this:
kong:
image: kong:latest
user: root
volumes:
- ./src/kong/:/root/kong/
environment:
KONG_DATABASE: "off"
KONG_DECLARATIVE_CONFIG: "/root/kong/kong.yml"
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'
networks:
- kong-net
ports:
- "8000:8000"
- "8443:8443"
- "127.0.0.1:8001:8001"
- "127.0.0.1:8444:8444"
restart: on-failure
networks:
kong-net:
name: kong-network
When I try to call my endpoint (which I’m running locally), I get this error message:
kong_1 | 2021/10/07 22:09:47 [error] 1097#0: *105 connect() failed (111: Connection refused) while connecting to upstream, client: 172.19.0.1, server: kong, request: "POST /registrations HTTP/1.1", upstream: "http://127.0.0.1:4556/", host: "127.0.0.1:8000"
kong_1 | 2021/10/07 22:09:47 [error] 1097#0: *105 connect() failed (111: Connection refused) while connecting to upstream, client: 172.19.0.1, server: kong, request: "POST /registrations HTTP/1.1", upstream: "http://127.0.0.1:4556/", host: "127.0.0.1:8000"
kong_1 | 2021/10/07 22:09:47 [error] 1097#0: *105 connect() failed (111: Connection refused) while connecting to upstream, client: 172.19.0.1, server: kong, request: "POST /registrations HTTP/1.1", upstream: "http://127.0.0.1:4556/", host: "127.0.0.1:8000"
kong_1 | 2021/10/07 22:09:47 [error] 1097#0: *105 connect() failed (111: Connection refused) while connecting to upstream, client: 172.19.0.1, server: kong, request: "POST /registrations HTTP/1.1", upstream: "http://127.0.0.1:4556/", host: "127.0.0.1:8000"
kong_1 | 2021/10/07 22:09:47 [error] 1097#0: *105 connect() failed (111: Connection refused) while connecting to upstream, client: 172.19.0.1, server: kong, request: "POST /registrations HTTP/1.1", upstream: "http://127.0.0.1:4556/", host: "127.0.0.1:8000"
kong_1 | 2021/10/07 22:09:47 [error] 1097#0: *105 connect() failed (111: Connection refused) while connecting to upstream, client: 172.19.0.1, server: kong, request: "POST /registrations HTTP/1.1", upstream: "http://127.0.0.1:4556/", host: "127.0.0.1:8000"
kong_1 | 172.19.0.1 - test_customer_id [07/Oct/2021:22:09:47 +0000] "POST /registrations HTTP/1.1" 502 75 "-" "PostmanRuntime/7.28.1"