Create a project in docker-compose where I have Kong, Konga (Web Admin), an API with your DB and Splunk to collect the logs.
The problem I have is that I cannot acquire the TCP IP addresses of those who consume the API through Kong.
From what I read you should configure these lines, on etc/kong/kong.conf.default. Is that so?
trusted_ips
real_ip_header = X-Real-IP
Here its my proyect
Logically I obtain, as a client, the IP address of my Kong container.
How could I modify the docker-compose so that this configuration is by default in the docker-compose up.
Thanks a lot for your help.
narate
2
Add the environment variable to Kong in Docker compose
- KONG_TRUSTED_IPS=0.0.0.0/0,::/0
- KONG_REAL_IP_RECURSIVE=on
1 Like
Hi narate, thanks for your help.
I add the fields:
#######################################
# Kong: The API Gateway
#######################################
kong:
image: ${KONG_DOCKER_TAG:-kong:latest}
restart: on-failure
networks:
- red
environment:
- KONG_DATABASE: postgres
- KONG_PG_HOST: kong-database
- KONG_PG_DATABASE: kong
- KONG_PG_USER: kong
- KONG_PG_PASSWORD: ${KONG_PG_PASSWORD:-kong}
- KONG_PROXY_LISTEN: 0.0.0.0:8000
- KONG_PROXY_LISTEN_SSL: 0.0.0.0:8443
- KONG_ADMIN_LISTEN: 0.0.0.0:8001
- KONG_PROXY_ERROR_LOG: /dev/stderr
- KONG_ADMIN_ERROR_LOG: /dev/stderr
- KONG_TRUSTED_IPS: 0.0.0.0/0,::/0
- KONG_REAL_IP_RECURSIVE: ON
links:
- api
depends_on:
- kong-database
healthcheck:
test: ["CMD", "kong", "health"]
interval: 10s
timeout: 10s
retries: 10
ports:
- "8000:8000"
- "8001:8001"
- "8443:8443"
- "8444:8444"
I keep getting the address of the Docker Gateway.
I’ll try changing docker’s network mode, but it shouldn’t be that. If something happens, don’t stop telling me. Thanks a lot.
narate
4
I tested on Linux with the docker-compose working fine, but Docker on macOS still get docker ip
1 Like