Search code examples
spring-bootdockerkong

How to configure kong-api to communicate other spring Microservice


I am just started with Kong API with One API I am able to run kong api locally using its official docker image available. And on other side I am having another Spring-Boot microservice locally running inside same Docker engine.

Problem : What configuration needs in kong api yaml file so that I can connect to my spring-boot microservice ?

My kong -api yaml file

services:
- name: control-service-integration
  url: http://localhost:8080/
  plugins:
  - name: oneapi
    config:
      edgemicro_proxy: edgemicro_demo_v0
      add_application_id_header: true
      authentication:
        apikey:
          header_name: "x-api-key"
      upstream_auth:
        basic_auth:
          username: username
          password: password 
        
  routes:
  - name: control-service-route
    request_buffering: false
    response_buffering: false
    paths:
    - /edgemicro-demo-v0

From kon-one api service i am getting always 502 Bad Gateway error. Let me know if anything information required.


Solution

  • I found the solution for this in above YAML

    services:
    - name: control-service-integration
      url: http://localhost:8080/
    

    add this value in-front of url section http://host.docker.internal:8080/ after doing lot of trials and errors finally now I am able to connect my app which is running on host.