问题描述
在 docker-compose 中创建一个项目,其中我有 Kong、Konga(Web 管理员)、一个带有数据库和 Splunk 的 API 来收集日志。
我遇到的问题是我无法通过Kong获取使用API的人的TCP IP地址。
根据我读到的内容,您应该在 etc/kong/kong.conf.default 上配置这些行。是这样吗?
- trusted_ips
- real_ip_header = X-Real-IP
这是我的proyect
从逻辑上讲,我作为客户端获取了我的 Kong 容器的 IP 地址。
我如何修改 docker-compose 以便此配置默认在 docker-compose up 中。
这是我的 docker-compose.yaml
version: '3'
services:
#######################################
# Database
#######################################
db:
image: MysqL:5.7
container_name: db
environment:
MysqL_ROOT_PASSWORD: secret
MysqL_DATABASE: maradona
MysqL_USER: maradona
MysqL_PASSWORD:
ports:
- "3306:3306"
volumes:
- dbdata:/var/lib/MysqL
- ./db/maradona.sql:/docker-entrypoint-initdb.d/init.sql
command: ['MysqLd','--character-set-server=utf8mb4','--collation-server=utf8mb4_unicode_ci']
networks:
- red
#######################################
# API Microservice
#######################################
api:
build: api/.
container_name: api
environment:
DATABASE: "db"
links:
- db
restart: always
ports:
- "5000:5000"
networks:
- red
#######################################
# Postgres: The database used by Kong
#######################################
kong-database:
image: postgres:9.6
container_name: kong-postgres
restart: on-failure
networks:
- red
volumes:
- kong_data:/var/lib/postgresql/data
environment:
POSTGRES_USER: kong
POSTGRES_PASSWORD: ${KONG_PG_PASSWORD:-kong}
POSTGRES_DB: kong
ports:
- "5432:5432"
healthcheck:
test: ["CMD","pg_isready","-U","kong"]
interval: 30s
timeout: 30s
retries: 3
#######################################
# Kong database migration
#######################################
kong-migration:
image: ${KONG_DOCKER_TAG:-kong:latest}
command: kong migrations bootstrap
networks:
- red
restart: on-failure
environment:
KONG_DATABASE: postgres
KONG_PG_HOST: kong-database
KONG_PG_DATABASE: kong
KONG_PG_USER: kong
KONG_PG_PASSWORD: ${KONG_PG_PASSWORD:-kong}
depends_on:
- kong-database
#######################################
# 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
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"
#######################################
# Konga database prepare
#######################################
konga-prepare:
image: pantsel/konga:latest
command: "-c prepare -a postgres -u postgresql://kong:${KONG_PG_PASSWORD:-kong}@kong-database:5432/konga"
networks:
- red
restart: on-failure
depends_on:
- kong-database
#######################################
# Konga: Kong GUI
#######################################
konga:
image: pantsel/konga:latest
restart: always
networks:
- red
environment:
DB_ADAPTER: postgres
DB_URI: postgresql://kong:${KONG_PG_PASSWORD:-kong}@kong-database:5432/konga
NODE_ENV: production
depends_on:
- kong-database
ports:
- "1337:1337"
#######################################
# Splunk Server
#######################################
splunk:
environment:
- TZ=America/Buenos_Aires
- SPLUNK_ENABLE_LISTEN=9997
- SPLUNK_START_ARGS=--accept-license --no-prompt --answer-yes
- SPLUNK_PASSWORD=password
hostname: splunk
image: splunk/splunk:latest
ports:
- "8888:8000"
- "8088:8088"
- "9997:9997"
- "1514:1514"
restart: always
networks:
- red
volumes:
dbdata:
config:
persist_volume:
kong_data: {}
opt-splunk-etc:
opt-splunk-var:
networks:
red:
driver: bridge
非常感谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)