### Install JWT Claims Headers Plugin in Kong Source: https://context7.com/sportecadev/sporteca-docs/llms.txt Manually install the JWT Claims Headers plugin by downloading, unzipping, and moving it to the appropriate directory within the Kong container. Register the plugin in kong.conf and restart the container. ```bash # SSH into the Kong container as root docker exec -u root -it kong /bin/bash # Download the plugin wget https://github.com/wshirey/kong-plugin-jwt-claims-headers/archive/master.zip # Unzip and install the plugin unzip master.zip mv kong-plugin-jwt-claims-headers-master /usr/local/share/lua/5.1/kong/plugins/jwt-claims-headers chown -R 1000.1000 /usr/local/share/lua/5.1/kong/plugins/jwt-claims-headers # Register the plugin in kong.conf cd /etc/kong cp kong.conf.default kong.conf # Edit kong.conf and add at the top: # plugins = bundled,jwt-claims-headers # Restart the container to apply changes ``` -------------------------------- ### Prepare Konga Database Source: https://github.com/sportecadev/sporteca-docs/blob/main/docs/source/kong-api-gateway/installl-kong-api-gateway.md Prepares the PostgreSQL database for Konga. This command should be run after the Konga container is started. ```bash docker run --rm --network=kong-net pantsel/konga -c prepare -a postgres -u postgresql://kong:kong@kong-database:5432/konga_db ``` -------------------------------- ### Create Docker Network for Kong Source: https://github.com/sportecadev/sporteca-docs/blob/main/docs/source/kong-api-gateway/installl-kong-api-gateway.md Creates a Docker network that will be used by the various containers for Kong installation. ```bash docker network create kong-net ``` -------------------------------- ### Configure ACL Plugin for Consumer Group Access Source: https://context7.com/sportecadev/sporteca-docs/llms.txt Enable the ACL plugin on a service to restrict access to specific consumer groups. Consumers must be assigned to a group before the plugin can enforce whitelisting. This example configures the 'sporteca-profile-service-v1' to only allow consumers in the 'sporteca-users' group. ```bash # In Konga UI: navigate to Consumers → select a consumer → Groups tab → Add group (e.g., "sporteca-users") # Enable ACL plugin on the profile service with the allowed group curl -X POST http://localhost:8001/services/sporteca-profile-service-v1/plugins \ --data "name=acl" \ --data "config.whitelist=sporteca-users" # Expected: HTTP 201 Created — only consumers in the "sporteca-users" group can now access the service ``` -------------------------------- ### Deploy Kong with PostgreSQL and Konga UI Source: https://context7.com/sportecadev/sporteca-docs/llms.txt Steps to set up the Kong API Gateway, its PostgreSQL database, and the Konga admin UI using Docker. Ensure the Docker network 'kong-net' is created first. Konga requires a separate PostgreSQL database named 'konga_db'. ```bash # Step 1 — Create a shared Docker network docker network create kong-net # Step 2 — Start PostgreSQL for Kong docker run -d --name kong-database \ --network=kong-net \ -p 5432:5432 \ -e "POSTGRES_USER=kong" \ -e "POSTGRES_DB=kong" \ -e "POSTGRES_PASSWORD=kong" \ postgres:9.6 # Step 3 — Bootstrap the Kong database docker run --rm --network=kong-net \ -e "KONG_DATABASE=postgres" \ -e "KONG_PG_HOST=kong-database" \ -e "KONG_PG_USER=kong" \ -e "KONG_PG_PASSWORD=kong" \ kong:latest kong migrations bootstrap # Step 4 — Start Kong Gateway docker run -d --name kong \ --network=kong-net \ -e "KONG_DATABASE=postgres" \ -e "KONG_PG_HOST=kong-database" \ -e "KONG_PG_USER=kong" \ -e "KONG_PG_PASSWORD=kong" \ -e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \ -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \ -e "KONG_PROXY_ERROR_LOG=/dev/stderr" \ -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \ -e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \ -p 8000:8000 \ -p 8443:8443 \ -p 127.0.0.1:8001:8001 \ -p 127.0.0.1:8444:8444 \ kong:latest # Verify Kong Admin API is reachable curl -i http://localhost:8001/ # Verify Kong Proxy is reachable curl -i http://localhost:8000/ # Prepare the Konga database docker run --rm --network=kong-net pantsel/konga:latest \ -c prepare -a postgres \ -u postgresql://kong:kong@kong-database:5432/konga_db # Start Konga (replace /path/to/kongdata with your host path) docker run -p 1337:1337 \ --network=kong-net \ -e "DB_ADAPTER=postgres" \ -e "DB_HOST=kong-database" \ -e "DB_USER=kong" \ -e "DB_DATABASE=konga_db" \ -e "KONGA_HOOK_TIMEOUT=120000" \ -e "NODE_ENV=production" \ --name konga \ pantsel/konga # Access Konga UI at: # http://localhost:1337/ # Create an admin account on first launch, then activate a Connection to http://kong:8001 ``` -------------------------------- ### Build and Deploy Sporteca Countries Microservice Source: https://context7.com/sportecadev/sporteca-docs/llms.txt Builds the Docker image for the Sporteca Countries microservice and runs it in a container, mapping the internal port to an external one. It then registers the service and its route with Kong. ```bash # Build and run the countries microservice docker build -t sporteca-countries-image . docker run --name sporteca-countries-container \ --network=kong-net \ -p 8082:8080 \ sporteca-countries-image ``` ```bash # Get container IP docker network inspect kong-net ``` ```bash # Register service and route on Kong curl -i -X POST \ --url http://localhost:8001/services/ \ --data 'name=sporteca-countries-service-v1' \ --data 'url=http://172.19.0.6:8080/' curl -i -X POST \ --url http://localhost:8001/services/sporteca-countries-service-v1/routes \ --data 'name=sporteca-countries-route-v1' \ --data 'paths[]=/sporteca-countries' ``` -------------------------------- ### Build and Deploy Sporteca Skills Microservice Source: https://context7.com/sportecadev/sporteca-docs/llms.txt Builds the Docker image for the Sporteca Skills microservice and runs it in a container, mapping the internal port to an external one. It then registers the service and its route with Kong. ```bash # Build and run the skills microservice docker build -t sporteca-skills-image . docker run --name sporteca-skills-container \ --network=kong-net \ -p 8084:8080 \ sporteca-skills-image ``` ```bash # Get container IP docker network inspect kong-net ``` ```bash # Register service and route on Kong curl -i -X POST \ --url http://localhost:8001/services/ \ --data 'name=sporteca-skills-service-v1' \ --data 'url=http://172.19.0.8:8080/' curl -i -X POST \ --url http://localhost:8001/services/sporteca-skills-service-v1/routes \ --data 'name=sporteca-skills-route-v1' \ --data 'paths[]=/sporteca-skills' ``` -------------------------------- ### Bootstrap Kong Database Migrations Source: https://github.com/sportecadev/sporteca-docs/blob/main/docs/source/kong-api-gateway/installl-kong-api-gateway.md Configures the PostgreSQL database for Kong Gateway by running database migrations. This prepares the database schema. ```bash docker run --rm --network=kong-net -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=kong-database" -e "KONG_PG_USER=kong" -e "KONG_PG_PASSWORD=kong" kong:latest kong migrations bootstrap ``` -------------------------------- ### Run Konga Container Source: https://github.com/sportecadev/sporteca-docs/blob/main/docs/source/kong-api-gateway/installl-kong-api-gateway.md Deploys the Konga UI container, mapping a host directory for data persistence. Replace with your desired path. ```bash docker run -d -p 1337:1337 --network=kong-net --name konga -v /kongadata:/app/kongadata -e "NODE_ENV=production" pantsel/konga ``` -------------------------------- ### Prepare Konga Database (Latest Tag) Source: https://github.com/sportecadev/sporteca-docs/blob/main/docs/source/kong-api-gateway/installl-kong-api-gateway.md An alternative command to prepare the PostgreSQL database for Konga, specifically using the 'latest' tag for the pantsel/konga image. ```bash docker run --rm --network=kong-net pantsel/konga:latest -c prepare -a postgres -u postgresql://kong:kong@kong-database:5432/konga_db ``` -------------------------------- ### Build and Deploy Sporteca Profile Microservice Source: https://context7.com/sportecadev/sporteca-docs/llms.txt Builds the Docker image for the Sporteca Profile microservice and runs it in a container, mapping the internal port to an external one. It also registers the service and its route with Kong. ```bash # Build and run the profile microservice docker build -t sporteca-profile-image . docker run --name sporteca-profile-container \ --network=kong-net \ -p 8083:8080 \ sporteca-profile-image ``` ```bash # Get container IP docker network inspect kong-net ``` ```bash # Register service and route on Kong curl -i -X POST \ --url http://localhost:8001/services/ \ --data 'name=sporteca-profile-service-v1' \ --data 'url=http://172.19.0.7:8080/' curl -i -X POST \ --url http://localhost:8001/services/sporteca-profile-service-v1/routes \ --data 'name=sporteca-profile-route-v1' \ --data 'paths[]=/sporteca-profile' ``` -------------------------------- ### Register Kong Service and Route Source: https://context7.com/sportecadev/sporteca-docs/llms.txt Commands to register a microservice as a 'service' in Kong and then create a 'route' for that service. Replace placeholders with actual service names and IP addresses. The 'url' parameter should include the IP address and port of the microservice container. ```bash # Generic command to register a service curl -i -X POST \ --url http://localhost:8001/services/ \ --data 'name=' \ --data 'url=' # Example: Register sporteca-auth curl -i -X POST \ --url http://localhost:8001/services/ \ --data 'name=sporteca-auth-service-v1' \ --data 'url=http://172.19.0.6:8080/' # After registering, create a route for the service curl -i -X POST \ --url http://localhost:8001/services/sporteca-auth-service-v1/routes \ --data 'name=sporteca-auth-route-v1' \ --data 'paths[]=/sporteca-auth' # Expected: HTTP 201 Created with the route object in the response body ``` -------------------------------- ### Run Konga Container with Environment Variables Source: https://github.com/sportecadev/sporteca-docs/blob/main/docs/source/kong-api-gateway/installl-kong-api-gateway.md Deploys the Konga UI container, configuring database connection and other settings via environment variables. This version does not explicitly map a volume for data persistence. ```bash docker run -p 1337:1337 --network=kong-net -e "DB_ADAPTER=postgres" -e "DB_HOST=kong-database" -e "DB_USER=kong" -e "DB_DATABASE=konga_db" -e "KONGA_HOOK_TIMEOUT=120000" -e "NODE_ENV=production" --name konga pantsel/konga ``` -------------------------------- ### Run PostgreSQL Container for Kong Source: https://github.com/sportecadev/sporteca-docs/blob/main/docs/source/kong-api-gateway/installl-kong-api-gateway.md Deploys a PostgreSQL container to serve as the database for Kong Gateway. Ensure the version is compatible. ```bash docker run -d --name kong-database --network=kong-net -p 5432:5432 -e “POSTGRES_USER=kong” -e “POSTGRES_DB=kong” -e "POSTGRES_PASSWORD=kong" postgres:9.6 ``` -------------------------------- ### Run Kong Gateway Container Source: https://github.com/sportecadev/sporteca-docs/blob/main/docs/source/kong-api-gateway/installl-kong-api-gateway.md Deploys the Kong Gateway container, configuring it to use the PostgreSQL database and setting up access logs and ports. ```bash docker run -d --name kong --network=kong-net -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=kong-database" -e "KONG_PG_USER=kong" -e "KONG_PG_PASSWORD=kong" -e "KONG_PROXY_ACCESS_LOG=/dev/stdout" -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" -e "KONG_PROXY_ERROR_LOG=/dev/stderr" -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" -e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" -p 8000:8000 -p 8443:8443 -p 127.0.0.1:8001:8001 -p 127.0.0.1:8444:8444 kong:latest ``` -------------------------------- ### Build and Deploy Sporteca Auth Microservice Source: https://context7.com/sportecadev/sporteca-docs/llms.txt Instructions for building the Docker image for the Sporteca Auth microservice and running it as a container on the 'kong-net' Docker network. The service is exposed on port 8081 on the host, mapping to port 8080 in the container. ```bash # Build the Docker image (run from the sporteca-auth-api project directory) docker build -t sporteca-auth-image . # Run the container on the kong-net network docker run --name sporteca-auth-container \ --network=kong-net \ -p 8081:8080 \ sporteca-auth-image # Inspect the network to find the container's IP address docker network inspect kong-net ``` -------------------------------- ### Create Kong Service via cURL Source: https://github.com/sportecadev/sporteca-docs/blob/main/docs/source/kong-api-gateway/installl-kong-api-gateway.md Use this cURL command to create a new service in Kong Gateway. Replace placeholders with your service name and its IP address and port. ```bash curl -i -X POST \ --url http://localhost:8001/services/ \ --data 'name=' \ --data 'url=' ``` -------------------------------- ### Check Kong Admin API Source: https://github.com/sportecadev/sporteca-docs/blob/main/docs/source/kong-api-gateway/installl-kong-api-gateway.md Verifies that the Kong Admin API is accessible and running. ```bash curl -i http://localhost:8001/ ``` -------------------------------- ### Check Kong Proxy API Source: https://github.com/sportecadev/sporteca-docs/blob/main/docs/source/kong-api-gateway/installl-kong-api-gateway.md Verifies that the Kong Proxy API is accessible and running. ```bash curl -i http://localhost:8000/ ``` -------------------------------- ### Register Sporteca Auth Service on Kong Source: https://context7.com/sportecadev/sporteca-docs/llms.txt Registers the 'sporteca-auth-service-v1' with Kong Gateway, specifying its container IP and port. This is a prerequisite for managing routes. ```bash curl -i -X POST \ --url http://localhost:8001/services/ \ --data 'name=sporteca-auth-service-v1' \ --data 'url=http://172.19.0.6:8080/' ``` ```bash curl -i -X POST \ --url http://localhost:8001/services/sporteca-auth-service-v1/routes \ --data 'name=sporteca-auth-route-v1' \ --data 'paths[]=/sporteca-auth' ``` -------------------------------- ### Enable JWT Plugin on Kong Service or Route Source: https://context7.com/sportecadev/sporteca-docs/llms.txt Applies the JWT plugin to a Kong service or a specific route. This enforces JWT validation for incoming requests, requiring a valid JWT in the Authorization header or as a query parameter. ```bash # Enable JWT plugin on a service curl -X POST http://localhost:8001/services/sporteca-profile-service-v1/plugins \ --data "name=jwt" ``` ```bash # Alternatively, enable JWT plugin on a specific route curl -X POST http://localhost:8001/routes/sporteca-profile-route-v1/plugins \ --data "name=jwt" ``` -------------------------------- ### Configure JWT Claims Headers Plugin Source: https://context7.com/sportecadev/sporteca-docs/llms.txt Configures the JWT Claims Headers plugin to unpack JWT payload claims and forward them as HTTP headers to the upstream service. This allows microservices to access user identity information without re-parsing the token. ```bash curl -X POST http://localhost:8001/services/sporteca-profile-service-v1/plugins \ --data "name=kong-plugin-jwt-claims-headers" \ --data "config.uri_param_names=jwt" \ --data "config.claims_to_include=.*" \ --data "config.continue_on_error=true" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.