Traefik mode host doesnt work on Centos, working fine with ubuntu (docker)

Hiii.,..
I need help, I have problem running Traefik on Centos. I tried to use mode: host to get client IP address.
However it doest work on Centos machine but working just fine with Ubuntu.
I need to get client real IP address from nginx. Internet ----> Traefik ---> Nginx
this is my docker-compose.yaml

services:
  traefik:
    image: traefik:v2.8
    ports:
      - target: 80
        published: 80
        mode: host
      - target: 443
        published: 443
        mode: host
    command:
      - --providers.docker=true
      - --providers.docker.swarmmode=true
      - --providers.docker.exposedbydefault=false
      - --providers.file.directory=/etc/traefik/dynamic-configs
      - --providers.file.watch=true
      - --entrypoints.web.address=:80
      - --entrypoints.websecure.address=:443
      - --accesslog
      - --log
      - --api

as many suggestion, I need to use mode: host however, if I use mode : host, traefik doesnt forward the request to Nginx. there are no error on the logs. is there any workaround to solve this problem.

Are your sure you didn't lose some configuration during migration? All labels on your nginx container still okay? Did you migrate from single node to swarm? Then labels go under deploy in docker-compose.yml when using docker stack.

For better investigation of your situation you can enable dashboard, debug log and access log.

I would test your Traefik setup with a simple whoami service:

service:
  whoami:
    image: traefik/whoami:v1.8
    networks:
      - proxy
    labels:
      - traefik.enable=true
      - traefik.http.routers.whoami.entrypoints=websecure
      - traefik.http.routers.whoami.rule=Host(`example.com`)
      - traefik.http.services.whoami.loadbalancer.server.port=80

PS: Update your Traefik version to latest release.

Update: you need to add TLS to the whoami labels if it’s not already configured on entrypoint.