# How do we get X-Forwarded-Port to either not be set or use the client requested port?

**URL:** <https://discuss.konghq.com/t/how-do-we-get-x-forwarded-port-to-either-not-be-set-or-use-the-client-requested-port/5900>\
**Category:** Questions\
**Created:** [March 30, 2020, 8:11pm UTC](https://discuss.konghq.com/t/how-do-we-get-x-forwarded-port-to-either-not-be-set-or-use-the-client-requested-port/5900 "2020-03-30T20:11:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nesl247](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/nesl247/32/1792_2.png) [@nesl247](https://discuss.konghq.com/u/nesl247)\
**Post date:** [March 30, 2020, 8:11pm UTC](https://discuss.konghq.com/t/how-do-we-get-x-forwarded-port-to-either-not-be-set-or-use-the-client-requested-port/5900/1 "2020-03-30T20:11:57Z")

</div>

We are using Kong on GKE behind a GCP Load Balancer. Kong is currently setting `X-Forwarded-For` to `8443`, which causes issues with some of our applications that forward based on this port. We would expect this port to be the original requested port of `443`.

---

<div class="post-metadata">

**Author:** ![hbagdi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/hbagdi/32/562_2.png) [@hbagdi](https://discuss.konghq.com/u/hbagdi)\
**Post date:** [March 31, 2020, 9:25pm UTC](https://discuss.konghq.com/t/how-do-we-get-x-forwarded-port-to-either-not-be-set-or-use-the-client-requested-port/5900/2 "2020-03-31T21:25:05Z")

</div>

Is the GCP Load balancer injecting a header? If so, Kong will respect that and not add it’s own.

---

<div class="post-metadata">

**Author:** ![nesl247](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/nesl247/32/1792_2.png) [@nesl247](https://discuss.konghq.com/u/nesl247)\
**Post date:** [March 31, 2020, 10:38pm UTC](https://discuss.konghq.com/t/how-do-we-get-x-forwarded-port-to-either-not-be-set-or-use-the-client-requested-port/5900/3 "2020-03-31T22:38:34Z")

</div>

It’s a L4 load balancer, not L7, so it’s not adding any of these. Kong is adding the header, and setting it to port `8443`.

---

<div class="post-metadata">

**Author:** ![hbagdi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/hbagdi/32/562_2.png) [@hbagdi](https://discuss.konghq.com/u/hbagdi)\
**Post date:** [April 1, 2020, 12:47am UTC](https://discuss.konghq.com/t/how-do-we-get-x-forwarded-port-to-either-not-be-set-or-use-the-client-requested-port/5900/4 "2020-04-01T00:47:33Z")

</div>

In that case, the only way to solve it is to run Kong with some privileges and make it listen on port 443.

---

<div class="post-metadata">

**Author:** ![nesl247](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/nesl247/32/1792_2.png) [@nesl247](https://discuss.konghq.com/u/nesl247)\
**Post date:** [April 7, 2020, 3:12pm UTC](https://discuss.konghq.com/t/how-do-we-get-x-forwarded-port-to-either-not-be-set-or-use-the-client-requested-port/5900/5 "2020-04-07T15:12:50Z")

</div>

Why isn’t this the default way to handle this in the helm chart? I tried to make it work, but realized we would also need a custom docker image as `setcap` needs to be run from what I can tell.

I’m not sure why kong would not function properly out of the box. Lots of other people have this issue as well.

---

<div class="post-metadata">

**Author:** ![hbagdi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/hbagdi/32/562_2.png) [@hbagdi](https://discuss.konghq.com/u/hbagdi)\
**Post date:** [April 7, 2020, 6:18pm UTC](https://discuss.konghq.com/t/how-do-we-get-x-forwarded-port-to-either-not-be-set-or-use-the-client-requested-port/5900/6 "2020-04-07T18:18:31Z")

</div>

You could try giving the permission to the pod and that might work: [https://www.weave.works/blog/container-capabilities-kubernetes/](https://www.weave.works/blog/container-capabilities-kubernetes/).

We are going to add a `kong.conf` option to override `X-Forwarded-Port`.
