pandafolks / panda

🚀 High-performance, All-in-one API Gateway
https://pandafolks.github.io/panda
Apache License 2.0
5 stars 0 forks source link

Use X-Forwarded-For header #108

Closed MattSzm closed 1 year ago

MattSzm commented 1 year ago

There are 2 use cases where this header might be useful and where at this moment we do NOT use it. The task is to provide support for it in such cases.

  1. Inside HashLoadBalancerImpl we make the decision to which instance the request is sent based on the Host value (https://github.com/pandafolks/panda/blob/master/loadBalancer/src/main/scala/com/github/pandafolks/panda/loadbalancer/HashLoadBalancerImpl.scala#:~:text=.map(_.host.toUriString)). The new implementation should first of all take the value from X-Forwarded-For header and only when it doesn't exist take the Host value.
  2. If the request does not contain the X-Forwarded-For header, we should add it inside the load balancers' logic (this value should be equal to the Host IP value). If the header already exists - do not modify it.