Reverse proxy locally what I would be doing wrong?

I am trying do configure my docker compose to use traefik as reverse proxy to my nodejs app.
It is running locally at host nodejsdeploy.betorobson which I have add a entry at hosts file to point out my local machine. So far my nodejs works by its own on port 3000.

So, it is working when I load on browser URL http://nodejsdeploy.betorobson:3000

My aim is to use traefik as reverse proxy on port 80.

Here is my docker compose which I am trying a few setups, you can see some comments lines which represent some of those frustrated setup that I have tried before.

Applying this compose setup, I can see the traefik dashboard running on port 8080, but when I try access the nodejs thought the port 80, it shows 404 page not found

version: "3"

services:
  app:
    labels:
      # - "traefik.backend=app"
      - "traefik.port=3000"
      - "traefik.enable=true"
      - "traefik.docker.network=proxy"
      - "traefik.frontend.rule=Host:nodejsdeploy.betorobson"
      # - "traefik.frontend.rule=Host:nodejsdeploy.betorobson"
      # - "traefik.docker.network=web"
      - "traefik.port=80"
    build: .
    ports:
      - "3000:3000"
    # networks:
    #   - internal
    #   - web
    command: yarn start

  reverse-proxy:
    image: traefik:latest
    # command: --api --docker.exposedbydefault=false
    # command: --api --api.insecure=true --docker.exposedbydefault=false --providers.docker

    # command: --api.insecure=true --providers.docker

    command:
     - --api.insecure=true
     - --providers.docker

    # command:
    #   - --api
    #   - --api.insecure=true
    #   - --docker
    #   # - --docker.swarmmode
    #   - --docker.watch
    #   # - --entrypoints=Name:http Address::80 Redirect.EntryPoint:https
    #   # - --entrypoints=Name:https Address::443 TLS
    #   # - --defaultentrypoints=http,https
    #   # - --acme
    #   # - --acme.email=jakub.hajek@cometari.com
    #   # - --acme.storage=/certificates/acme.json
    #   # - --acme.entryPoint=https
    #   # - --acme.httpChallenge.entryPoint=http
    #   # - --acme.onhostrule=true
    #   # - --acme.acmelogging=true
    #   # - --logLevel=INFO
    #   # - --accessLog
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

  # whoami:
  #   image: containous/whoami
  #   labels:
  #     - "traefik.http.routers.whoami.rule=Host(`nodejsdeploy.betorobson`)"

Docker file

FROM node:10-alpine

WORKDIR /usr/app
COPY package.json yarn.lock ./

RUN yarn

COPY . .

EXPOSE 3000
CMD ["yarn", "start"]

Hello,

you are using the Traefik v1 labels with Traefik v2, it's not possible.

Always use an explicit version instead of latest: ex traefik:v2.1, traefik:v1.7

1 Like