# Traefik and X-Forwarded-Proto

**URL:** <https://community.traefik.io/t/traefik-and-x-forwarded-proto/19240>\
**Category:** Traefik v2\
**Tags:** middleware\
**Created:** [July 16, 2023, 5:20am UTC](https://community.traefik.io/t/traefik-and-x-forwarded-proto/19240 "2023-07-16T05:20:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Orwill](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/orwill/32/1671_2.png) [@Orwill](https://community.traefik.io/u/Orwill)\
**Post date:** [July 16, 2023, 5:20am UTC](https://community.traefik.io/t/traefik-and-x-forwarded-proto/19240/1 "2023-07-16T05:20:26Z")

</div>

Hello everyone.

I was trying to add `X-Forwarded-Proto` header to the request using middleware, but it did not work.

I found this article [How to configure X-Forwarded-For and X-Forwarded-Proto in v2? - Traefik / Traefik v2 (latest) - Traefik Labs Community Forum](https://community.traefik.io/t/how-to-configure-x-forwarded-for-and-x-forwarded-proto-in-v2/7720) said I have to set `forwardedHeaders`, but it confused me a lot. My kubernetes setup make sure traefik could get the real ip directly, so I just can't figure out which ip should I trust. And also why you need to trust some ip to make a middleware work? That makes no sense to me.

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [July 16, 2023, 12:30pm UTC](https://community.traefik.io/t/traefik-and-x-forwarded-proto/19240/2 "2023-07-16T12:30:40Z")

</div>

I recommend to add the k8s tag to your post.
