Traefik v2.5 not redirecting to portainer container. 404 Not Found

Viewed 453

I am trying to get traefik work with portainer but nothing so far. My goal is to just type http://localhost/portainer and let traefik redirect to portainer portal.

So far my docker-compose looks like this:

services:
  reverse-proxy:
    image: traefik
    container_name: "traefik"
    networks:
      - traefik_net
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "./traefik.yml:/traefik.yml:ro"

  portainer:
    image: "portainer/portainer-ce"
    container_name: "portainer"
    networks:
      - traefik_net
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - portainer_data:/data"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.portainer.entrypoints=web"
      - "traefik.http.routers.portainer.rule=Host(`localhost`) && PathPrefix(`/portainer`)"
      - "traefik.http.services.portainer.loadbalancer.server.port=9000"
networks:
  traefik_net: {}
volumes:
  portainer_data:

And my traefik.yml file is:

log:
  level: INFO

api:
  insecure: true
  dashboard: true

entryPoints:
  web:
    address: ":80"

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false

I really do not know what is going on. When I try to connect to http://localhost/portainer I get 404 not found.

The dashboard is working fine. When I check the portainer servece is has the docker ip for portainer container and also the port 9000 so I think the problem is with the traefik receiving and redirecting the url to the portainer container.

Any help is welcomed, thanks.

1 Answers
Related