2019-11-12 14:40:05 +00:00
|
|
|
```yaml tab="Docker"
|
|
|
|
# Dynamic Configuration
|
|
|
|
labels:
|
|
|
|
- "traefik.http.routers.api.rule=Host(`traefik.domain.com`)"
|
|
|
|
- "traefik.http.routers.api.service=api@internal"
|
|
|
|
- "traefik.http.routers.api.middlewares=auth"
|
|
|
|
- "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0"
|
|
|
|
```
|
|
|
|
|
|
|
|
```yaml tab="Docker (Swarm)"
|
|
|
|
# Dynamic Configuration
|
|
|
|
deploy:
|
|
|
|
labels:
|
|
|
|
- "traefik.http.routers.api.rule=Host(`traefik.domain.com`)"
|
|
|
|
- "traefik.http.routers.api.service=api@internal"
|
|
|
|
- "traefik.http.routers.api.middlewares=auth"
|
|
|
|
- "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0"
|
|
|
|
# Dummy service for Swarm port detection. The port can be any valid integer value.
|
|
|
|
- "traefik.http.services.dummy-svc.loadbalancer.server.port=9999"
|
|
|
|
```
|
|
|
|
|
2019-12-13 09:36:04 +00:00
|
|
|
```yaml tab="Kubernetes CRD"
|
|
|
|
apiVersion: traefik.containo.us/v1alpha1
|
|
|
|
kind: IngressRoute
|
|
|
|
metadata:
|
|
|
|
name: traefik-dashboard
|
|
|
|
spec:
|
|
|
|
routes:
|
|
|
|
- match: Host(`traefik.domain.com`)
|
|
|
|
kind: Rule
|
|
|
|
services:
|
|
|
|
- name: api@internal
|
|
|
|
kind: TraefikService
|
|
|
|
---
|
|
|
|
apiVersion: traefik.containo.us/v1alpha1
|
|
|
|
kind: Middleware
|
|
|
|
metadata:
|
|
|
|
name: auth
|
|
|
|
spec:
|
|
|
|
basicAuth:
|
|
|
|
secret: secretName # Kubernetes secret named "secretName"
|
|
|
|
```
|
|
|
|
|
2019-11-15 12:34:41 +00:00
|
|
|
```yaml tab="Consul Catalog"
|
|
|
|
# Dynamic Configuration
|
|
|
|
- "traefik.http.routers.api.rule=Host(`traefik.domain.com`)"
|
|
|
|
- "traefik.http.routers.api.service=api@internal"
|
|
|
|
- "traefik.http.routers.api.middlewares=auth"
|
|
|
|
- "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0"
|
|
|
|
```
|
|
|
|
|
2019-11-12 14:40:05 +00:00
|
|
|
```json tab="Marathon"
|
|
|
|
"labels": {
|
|
|
|
"traefik.http.routers.api.rule": "Host(`traefik.domain.com`)",
|
|
|
|
"traefik.http.routers.api.service": "api@internal",
|
|
|
|
"traefik.http.routers.api.middlewares": "auth",
|
|
|
|
"traefik.http.middlewares.auth.basicauth.users": "test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
```yaml tab="Rancher"
|
|
|
|
# Dynamic Configuration
|
|
|
|
labels:
|
|
|
|
- "traefik.http.routers.api.rule=Host(`traefik.domain.com`)"
|
|
|
|
- "traefik.http.routers.api.service=api@internal"
|
|
|
|
- "traefik.http.routers.api.middlewares=auth"
|
|
|
|
- "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0"
|
|
|
|
```
|
|
|
|
|
|
|
|
```toml tab="File (TOML)"
|
|
|
|
# Dynamic Configuration
|
|
|
|
[http.routers.my-api]
|
|
|
|
rule = "Host(`traefik.domain.com`)"
|
|
|
|
service = "api@internal"
|
|
|
|
middlewares = ["auth"]
|
|
|
|
|
|
|
|
[http.middlewares.auth.basicAuth]
|
|
|
|
users = [
|
|
|
|
"test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/",
|
|
|
|
"test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0",
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
```yaml tab="File (YAML)"
|
|
|
|
# Dynamic Configuration
|
|
|
|
http:
|
|
|
|
routers:
|
|
|
|
api:
|
|
|
|
rule: Host(`traefik.domain.com`)
|
|
|
|
service: api@internal
|
|
|
|
middlewares:
|
|
|
|
- auth
|
|
|
|
middlewares:
|
|
|
|
auth:
|
|
|
|
basicAuth:
|
|
|
|
users:
|
|
|
|
- "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/"
|
|
|
|
- "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"
|
|
|
|
```
|