Attempting to setup basic auth with traffic, using yml files with the following setup.
middlewares.yml - basic auth middleware only
http:
middlewares:
basic-auth:
basicAuth:
usersFile: /shared/.htpasswd
traefik.yml - Traefik configs only focused on api and dashboard functionality
api:
dashboard: true
entryPoints:
web:
address: ":80"
websecure:
address: ":443"
traefik:
address: ":8080"
global:
checknewversion: true
# sendanonymoususage: true
log:
level: DEBUG
# filepath: /traefik.event.log
format: json
accesslog:
filepath: /traefik.access.log
format: json
bufferingsize: 100
filters:
statusCodes: 400-599
providers:
docker:
exposedByDefault: false
swarmMode: false
file:
watch: true
directory: "/rules"
app-dashboard.yml - file providing router setup for API and dashboard
http:
routers:
traefik:
entryPoints: web
rule: "Host(`traefik.docker.localhost`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
service: api@internal
middlewares:
- basic-auth@file
Docker-compose.yml file putting it all together and firing things up
version: "3.8"
networks:
t2_proxy:
external: true
default:
driver: bridge
services:
reverse-proxy:
# The official v2.0 Traefik docker image
image: traefik:latest
container_name: traefik
# Enables the web UI and tells Traefik to listen to docker
ports:
# The HTTP port
- target: 80
published: 80
protocol: tcp
mode: host
# The Web UI (enabled by --api.insecure=true)
- target: 8080
published: 8080
protocol: tcp
mode: host
- target: 443
published: 443
protocol: tcp
mode: host
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock:ro
- ${docker_dir}\traefik\rules:/rules
- ${docker_dir}\traefik\traefik.yml:/traefik.yml:ro
- ${docker_dir}\traefik\traefik.access.log:/traefik.access.log
- ${docker_dir}\shared\.htpasswd:/shared/.htpasswd
networks:
- t2_proxy
ultimately this setup leads me to 404 errors no matter what I try to get to
traefik.docker.localhost
traefik.docker.localhost/dashbaord
traefik.docker.localhost/api/rawdata
traefik.docker.localhost:8080/dashboard
traefik.docker.localhost:8080/api/rawdata