# Real IP and Host Header

**URL:** <https://community.traefik.io/t/real-ip-and-host-header/12336>\
**Category:** Traefik v2\
**Tags:** cli, docker\
**Created:** [November 3, 2021, 8:23pm UTC](https://community.traefik.io/t/real-ip-and-host-header/12336 "2021-11-03T20:23:18Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanW](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@DanW](https://community.traefik.io/u/DanW)\
**Post date:** [November 3, 2021, 8:23pm UTC](https://community.traefik.io/t/real-ip-and-host-header/12336/1 "2021-11-03T20:23:18Z")

</div>

Could anybody help me on how to pass the real IP address and host header in Traefik please? I have a file provider that proxies connects to my Open Media Vault Control Panel but the logs still report that Traefik's IP address are the one contacting it rather than the IP from the originating source.

---

<div class="post-metadata">

**Author:** ![jakubhajek](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/jakubhajek/32/3389_2.png) [@jakubhajek](https://community.traefik.io/u/jakubhajek)\
**Post date:** [November 4, 2021, 3:44pm UTC](https://community.traefik.io/t/real-ip-and-host-header/12336/2 "2021-11-04T15:44:04Z")

</div>

Hello @DanW

thanks for using Traefik and asking the question.

I would recommend you to see the following docs:

- forwarded Headers [EntryPoints - Traefik](https://doc.traefik.io/traefik/routing/entrypoints/#forwarded-headers)

Then the real IP address should be available in the X-Forwarded header.

If you deploy Traefik on Kubernetes with service type Loadbalancer, the externalTrafficPolicy should be also updated.

Thank you

---

<div class="post-metadata">

**Author:** ![DanW](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@DanW](https://community.traefik.io/u/DanW)\
**Post date:** [November 4, 2021, 6:52pm UTC](https://community.traefik.io/t/real-ip-and-host-header/12336/3 "2021-11-04T18:52:35Z")

</div>

Hi @jakubhajek thank you so much for your response! So does traffic pass the X-Forwarded header by default and it is just a matter of getting Traefik to trust the forwarded headers then?

---

<div class="post-metadata">

**Author:** ![jakubhajek](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/jakubhajek/32/3389_2.png) [@jakubhajek](https://community.traefik.io/u/jakubhajek)\
**Post date:** [November 9, 2021, 10:33am UTC](https://community.traefik.io/t/real-ip-and-host-header/12336/4 "2021-11-09T10:33:02Z")

</div>

Hello @DanW

The header X-Forwarded-for is being passed by default. However, in order to get a real IP address, the trust headers mechanism has to be configured.

For testing purposes, it can be set in `insecure` mode.

Thank you,  
Jakub

---

<div class="post-metadata">

**Author:** ![decypher\_the\_world](https://avatars.discourse-cdn.com/v4/letter/d/9de053/32.png) [@decypher\_the\_world](https://community.traefik.io/u/decypher_the_world)\
**Post date:** [August 5, 2022, 9:02am UTC](https://community.traefik.io/t/real-ip-and-host-header/12336/5 "2022-08-05T09:02:14Z")

</div>

why can't traefik have a way to easily get the real ip of user? Every other software/website i use in the world does this or is this a rocket science to implement?

As a reverse proxy, i think it is safe to say most people want this. So why have us waste so much time and energy for something that is widely needed??????

We have to drill into forwarded headers to figure this out ourselves? cloudflare for example passes this as response header with `Cf-Connecting-Ip` and am sure others have a way of passing this, so why can't traefik implement this that makes sense to be on traefik layer?

---

<div class="post-metadata">

**Author:** ![yaya](https://avatars.discourse-cdn.com/v4/letter/y/cdc98d/32.png) [@yaya](https://community.traefik.io/u/yaya)\
**Post date:** [May 17, 2023, 6:51am UTC](https://community.traefik.io/t/real-ip-and-host-header/12336/6 "2023-05-17T06:51:23Z")

</div>

Hi,

We are soon in 2024! 2 years after this thread was opened no one has been able to solve this problem. Just yesterday, other people opened topics on this subject. Lots of people on lots of forums are asking this question.

Personally, I gave up the idea of ​​having my visitors' IPs with Traefik after several months of active research. I have tried many solutions without success. It could perhaps come from the infrastructure.  
As long as there is no solution, I had to remove Traefik from the production for security reasons. I find it surprising that there is no official support for this because it’s very important and so basic for an ingress controller.  
The community needs support on this.

---

<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:** [May 17, 2023, 11:55am UTC](https://community.traefik.io/t/real-ip-and-host-header/12336/7 "2023-05-17T11:55:08Z")

</div>

We use ProxyProtocol with Traefik and everything works for us.

---

<div class="post-metadata">

**Author:** ![Dojo](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/dojo/32/7478_2.png) [@Dojo](https://community.traefik.io/u/Dojo)\
**Post date:** [August 19, 2023, 7:58pm UTC](https://community.traefik.io/t/real-ip-and-host-header/12336/8 "2023-08-19T19:58:16Z")

</div>

Please share your configuration. I am running into same issues - no solution so far.  
Just tested "forwardedHeaders.insecure" and "proxyProtocol.insecure" =\> same results - no "real visitors ips".

---

<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:** [August 20, 2023, 7:32am UTC](https://community.traefik.io/t/real-ip-and-host-header/12336/9 "2023-08-20T07:32:49Z")

</div>

ProxyProtocol can be used with Traefik on 2 sides: one is entrypoint to receive PP for example from a load balancer, and on the service side to send PP to the target service, which is usually TCP only and needs to understand PP.

---

<div class="post-metadata">

**Author:** ![Dojo](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/dojo/32/7478_2.png) [@Dojo](https://community.traefik.io/u/Dojo)\
**Post date:** [September 26, 2023, 7:48pm UTC](https://community.traefik.io/t/real-ip-and-host-header/12336/10 "2023-09-26T19:48:59Z")

</div>

this did the trick for me:

docker-compose.yaml

```auto
    ports:
      - target: 80
        published: 80
        protocol: tcp
        mode: host
      - target: 443
        published: 443
        protocol: tcp
        mode: host

```

---

<div class="post-metadata">

**Author:** ![vmpartner](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/vmpartner/32/10196_2.png) [@vmpartner](https://community.traefik.io/u/vmpartner)\
**Post date:** [March 26, 2025, 9:32pm UTC](https://community.traefik.io/t/real-ip-and-host-header/12336/11 "2025-03-26T21:32:15Z")

</div>

if you on bare metal you must pass headers yourself

```auto
labels:
  - "traefik.http.middlewares.add-forwarded-headers.headers.customrequestheaders.X-Forwarded-For=${remote_ip}"
  - "traefik.http.middlewares.add-forwarded-headers.headers.customrequestheaders.X-Real-Ip=${remote_ip}"

```

---

<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:** [March 26, 2025, 9:46pm UTC](https://community.traefik.io/t/real-ip-and-host-header/12336/12 "2025-03-26T21:46:44Z")

</div>

I don't think this is correct. Where is `remote_ip` value coming from?

Traefik will automatically set those headers.
