I am using traefik version 2(or 2.x) and I want to forward all the request from port 80 to different port like 8081 with traefik router. So request like http://localhost/xx will be forwarded to http://localhost:8081/xx URL.
I am newbie with traefik and I am using docker for this configuration. Below is my docker-compose.yml file configuration. After configuring this traefik dashboard is loaded on http://localhost:8080/dashboard/#/ URL but request forwarding is not worked.
version: "3"
services:
traefik:
image: "traefik:v2.1.0"
container_name: "traefik"
command:
- "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
whoami:
image: "containous/whoami"
container_name: "simple-service"
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.entrypoints=web"
- "traefik.http.services.whoami.loadbalancer.server.port=8081"
- "traefik.docker.network=proxy"
- "traefik.http.routers.whoami.rule=Host(`localhost`)"
Any help on this would be appreciated.