# How to forward request IP to service in Traefik v2?

**URL:** <https://community.traefik.io/t/how-to-forward-request-ip-to-service-in-traefik-v2/2047>\
**Category:** Traefik v2\
**Tags:** docker\
**Created:** [September 30, 2019, 2:14pm UTC](https://community.traefik.io/t/how-to-forward-request-ip-to-service-in-traefik-v2/2047 "2019-09-30T14:14:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![traefiker1](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@traefiker1](https://community.traefik.io/u/traefiker1)\
**Post date:** [September 30, 2019, 2:14pm UTC](https://community.traefik.io/t/how-to-forward-request-ip-to-service-in-traefik-v2/2047/1 "2019-09-30T14:14:13Z")

</div>

How to forward the user's real IP to a service?

I am using Traefik v2 in Docker swarm.  
Currently I get only an IP starting with 10.x.x.x.

---

<div class="post-metadata">

**Author:** ![Ch1ch1](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ch1ch1/32/710_2.png) [@Ch1ch1](https://community.traefik.io/u/Ch1ch1)\
**Post date:** [September 30, 2019, 2:26pm UTC](https://community.traefik.io/t/how-to-forward-request-ip-to-service-in-traefik-v2/2047/2 "2019-09-30T14:26:38Z")

</div>

HELLO

You have to publish the port in host mode :

Example

```auto
version: "3.6"

services:

  app:
    image: "traefik:v2.0.0"

    ports:
      - target: 80
        published: 80
        protocol: tcp
        mode: host
      - target: 443
        published: 443
        protocol: tcp
        mode: host
        .....

```

---

<div class="post-metadata">

**Author:** ![zespri](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/zespri/32/310_2.png) [@zespri](https://community.traefik.io/u/zespri)\
**Post date:** [September 30, 2019, 6:37pm UTC](https://community.traefik.io/t/how-to-forward-request-ip-to-service-in-traefik-v2/2047/3 "2019-09-30T18:37:45Z")

</div>

Would like to add, that this question crops up every now and then. Basically Traefik cannot add Real IP if it does not know it. And depending on docker configuration, sometimes you get only packets with internal source IP from docker. Those concerns really should be addressed in the docker community since they have little to do with traefik. That is not to say, that it's in any shape of form "bad" to answer them here - on the opposite, it's just that the topic is expansive (swarm vs plain, linux vs windows all have their own docker networking quircks), and if it is not addressed here, it would be no surprise.

---

<div class="post-metadata">

**Author:** ![traefiker1](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@traefiker1](https://community.traefik.io/u/traefiker1)\
**Post date:** [October 1, 2019, 8:12am UTC](https://community.traefik.io/t/how-to-forward-request-ip-to-service-in-traefik-v2/2047/4 "2019-10-01T08:12:34Z")

</div>

Thank you both of you. For me, adding host mode solves the issue.

---

<div class="post-metadata">

**Author:** ![JMarji](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/jmarji/32/4202_2.png) [@JMarji](https://community.traefik.io/u/JMarji)\
**Post date:** [December 22, 2021, 6:09am UTC](https://community.traefik.io/t/how-to-forward-request-ip-to-service-in-traefik-v2/2047/5 "2021-12-22T06:09:11Z")

</div>

Thank you guys, the solution listed above also worked for me.
