Hi everybody, I am using Kong as an API Gateway and Keycloak for authentication services. I have a dedicated Linux server, and I am using Plesk for server management. I run all services in Docker Compose. I created a subdomain and made port forwarding from Kong Container to my subdomain. My problem is this: When I try to reach Keyclaok, I use this URL. https://.domain>/auth, but it redirects me to the https://. :8000/auth. Because the Kong service is already forwarded to the URL, I don’t need the port. I could not solve this problem. Anyone who has had a similar experience I drop my kong.yml and docker-compose files here. I deleted passwords and sensitive data.
kong.yaml
_format_version: "1.1"
services:
- name: keycloak_auth
host: keycloak
protocol: http
port: 8080
routes:
- name: keycloak-route
paths:
- /auth
strip_path: false
preserve_host: true
- name: frontend
host: frontend
protocol: http
port: 3001
routes:
- name: frontend_route
paths:
- /
strip_path: false
preserve_host: true
- name: backend
host: backend
protocol: http
port: 9999
routes:
- name: backend_route
paths:
- /backend
docker-compose.yml
version: '3'
services:
backend:
image: backend
restart: always
entrypoint: ./development-entrypoint.sh
container_name: backend
ports:
- 9001:9999
environment:
depends_on:
- postgres
- kong
postgres:
image: postgres:alpine
environment:
- POSTGRES_USER=
- POSTGRES_PASSWORD=
- POSTGRES_DB=
volumes:
- ./docker_postgres_init.sql:/docker-entrypoint-initdb.d/docker_postgres_init.sql
- ./postgres:/var/lib/postgresql/data
kong:
build:
context: ..
dockerfile: docker/kong/Dockerfile.kong
container_name: api_gateway
restart: always
ports:
- "8002:8000"
- "8445:8443"
- "8001:8001"
- "8444:8444"
volumes:
- ./kong/kong.yml:/kong.yml
- ./kong/kong.conf:/etc/kong/kong.conf
environment:
KONG_DATABASE: "off"
KONG_DECLARATIVE_CONFIG: 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_LOG_LEVEL: warn
KONG_ADMIN_LISTEN: 0.0.0.0:8001, 0.0.0.0:8444 ssl
KONG_PROXY_LISTEN: 0.0.0.0:8000, 0.0.0.0:8443 ssl, 0.0.0.0:9080 http2, 0.0.0.0:9081 http2 ssl
KONG_PLUGINS: oidc
KC_HTTPS_PORT: 8445
keycloak:
image: jboss/keycloak
container_name: keycloak
environment:
- DB_VENDOR=
- DB_ADDR=
- DB_DATABASE=
- DB_USER=
- DB_PASSWORD=
- KEYCLOAK_USER=
- KEYCLOAK_PASSWORD=
- KC_PROXY=
- PROXY_ADDRESS_FORWARDING=
ports:
- "8888:8080"
depends_on:
- postgres
frontend:
image: frontend
container_name: frontend
ports:
- 3334:3001
- 9228:9229
command: ["node", "--inspect=0.0.0.0:9229", "index.js"]
restart: unless-stopped