What am I doing wrong?

I am just trying to setup a local developing environment. The applications are just there so I can get better with labels and routing. When I run docker-compose up I get a 404 not found on localhost and a bad gateway on the dashboard at web.localhost. Influx gives me no problems. All I am trying to accomplish with this setup is to have website on the main domain with a dashboard and another sub domain running another application.

version: '3'

services:
  traefik:
    image: traefik:v1.7
    command: --docker
    ports:
      - 80:80
    networks:
      - proxy
    labels:
      - "traefik.frontend.rule=Host:web.localhost"
      - "traefik.port=8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
  nginx:
    image: nginx:latest
    networks:
      - proxy
    labels: 
      - "traefik.frondend.rule=PathPrefix:/static/"
  influxdb:
    image: quay.io/influxdb/influxdb:2.0.0-alpha
    networks: 
      - proxy
    labels:
      - "traefik.enable=true"
      - "traefik.backend=influx"
      - "traefik.frontend.rule=Host:influx.localhost"
      - "traefik.docker.network=proxy"
      - "traefik.port=9999"
networks: 
  proxy:
    external: 
      name: proxy
  internal:
    external: false

traefik.toml

[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "localhost"
watch = true
exposedByDefault = true

[web]
address=":8080"
  [web.auth.basic]
  users = ["admin:$apr1$A3524hz3$4k45BqlgN1aiwOs1pjMD9."]

Try:
- traefik.frontend.rule: 'Host:web.localhost'

Instead of:
- "traefik.frontend.rule="Host:web.localhost"

And set traefik.docker.network and traefik.enable: 'true'

Whats the difference between the first frontend rule and the second besides spaces?

traefik_1   | time="2019-06-25T23:11:45Z" level=error msg="error creating route for frontend frontend-Host-web-localhost-0: error parsing rule: error parsing rule: ' 'Host:web.localhost''. Unknown function: ' 'Host'. Skipping frontend frontend-Host-web-localhost-0..."

I dont understand why does the influx container work?

404 means cannot match your rule, 502 means that rule is matched but cannot connect to the backend. Your 502 is not surprising since you need to have something to reply on 8080 and you don’t. It does not seem that you have a rule for “localhost”, so 404 is also expected.

If you change command: --docker to command: ["--api","--docker"] you should be able to see the dashboard. If you correct your spelling mistake, and write frontend with t, you also should be able to browse to http://web.localhost/static/ and get 404 form nginx.

Your traefik.toml does not seem to be used.

This worked. I appreciate it. Now I have nginx a localhost and the dashboard at web.localhost.
I attached the toml in the volumes but basic authentication is not working?

version: '3'

services:
  traefik:
    image: traefik:v1.7
    command: --api --docker
    ports:
      - 80:80
    networks:
      - proxy
    labels:
      - "traefik.frontend.rule=Host:web.localhost"
      - "traefik.port=8080"
    volumes:
      - ./traefik.toml:/traefik.toml
      - /var/run/docker.sock:/var/run/docker.sock
  nginx:
    image: nginx:latest
    networks:
      - proxy
    labels: 
      - "traefik.enable=true"
      - "traefik.frontend.rule=PathPrefix:/static/"
      - "traefik.docker.network=proxy"
  influxdb:
    image: quay.io/influxdb/influxdb:2.0.0-alpha
    networks: 
      - proxy
    labels:
      - "traefik.enable=true"
      - "traefik.backend=influx"
      - "traefik.frontend.rule=Host:influx.localhost"
      - "traefik.docker.network=proxy"
      - "traefik.port=9999"
networks: 
  proxy:
    external: 
      name: proxy
  internal:
    external: false
[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "localhost"
watch = true
exposedByDefault = true

[web]
address=":8080"
  [web.auth.basic]
  users = ["admin:$apr1$A3524hz3$4k45BqlgN1aiwOs1pjMD9."]

Hello,

[web] is deprecated https://docs.traefik.io/v1.7/configuration/backends/web/ and replaced by [api] https://docs.traefik.io/v1.7/configuration/api/

To enable basic auth on the api: https://docs.traefik.io/v1.7/configuration/api/#authentication

I recommend to not mix CLI arguments and TOML configuration on the same section (ex: docker), for more explanation you can read https://docs.traefik.io/v.7/basics/#static-traefik-configuration

Hey @ldez thanks for pointing me in the right direction. The solution was so simple because I was trying to use both CLI and toml at the same time. That is why I was getting the error message.
I had to remove the CLI --api argument so the toml would work correctly.

commands: --api --docker