logo jittagornp.me

Setup Kong Loadbalancing

headers for all requests

Content-Type : application/json  

1. Add Upstreams server

1.1 set upstream name
http post

http://<GATEWAY_IP>:8001/upstreams

body

{
  "name" : "oauth.v1.service"    
}

1.2 set target servers under upstream http post

http://<GATEWAY_IP>:8001/upstreams/oauth.v1.service/targets

body

target server 1

{
  "target" : "10.130.50.115:30001",
  "weight" : 50
}

target server 2

{
  "target" : "10.130.12.164:30001",
  "weight" : 50
}

2. Add Service

http post

http://<GATEWAY_IP>:8001/services

body

{
  "name" : "oauth-service",
  "host" : "oauth.v1.service",
  "path" : "/"
}

3. Add Route under service

http post

http://<GATEWAY_IP>:8001/services/oauth-service/routes

body

{
  "hosts" : ["auth.mydomainname.com"],
  "paths" : ["/oauth/v1"]
}

4. Test Access

https://auth.mydomainname.com/oauth/v1

Reference

https://docs.konghq.com/1.4.x/loadbalancing/

Table of Contents

สำหรับเพื่อน ๆ คนไหน ที่ชื่นชอบบทความ และอยากจะสนุนสนันค่ากาแฟเล็ก ๆ น้อย ๆ สามารถคลิกที่ปุ่มนี้เพื่อไปยังหน้า Buy me a coffee ได้ครับ
profile photo
จิตกร พิทักษ์เมธากุล fire fire fire
วิศกรซอฟต์แวร์ ที่หลงรักการเขียนซอฟต์แวร์ และมีความสุขกับการได้อยู่กับครอบครัว ♥️