Traefik Docker Swarm: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
| Zeile 51: | Zeile 51: | ||
* '''cd ''apache2'' ''' | * '''cd ''apache2'' ''' | ||
* '''vim ''docker-stack.yml'' ''' | * '''vim ''docker-stack.yml'' ''' | ||
| + | |||
| + | <syntaxhighlight lang="yaml"> | ||
| + | version: "3.7" | ||
| + | services: | ||
| + | my_web: | ||
| + | image: ubuntu/apache2 | ||
| + | networks: | ||
| + | - test-net | ||
| + | deploy: | ||
| + | replicas: 2 | ||
| + | labels: | ||
| + | - "traefik.http.services.my_web.loadbalancer.server.port=80" | ||
| + | - "traefik.http.routers.my_web.rule=Host(`apache.ubuntu`) || PathPrefix(`/apache`)" | ||
| + | #- "traefik.http.middlewares.test-auth.basicauth.usersfile=/auth/users.auth" | ||
| + | - "traefik.http.middlewares.test-path.replacepathregex.regex=^/apache(.*)" | ||
| + | - "traefik.http.middlewares.test-path.replacepathregex.replacement=/$$1" | ||
| + | - "traefik.http.routers.my_web.middlewares=test-path" | ||
| + | #- "traefik.http.routers.my_web.middlewares=test-auth" | ||
| + | volumes: | ||
| + | - ./html/:/var/www/html/ | ||
| + | |||
| + | networks: | ||
| + | test-net: | ||
| + | driver: overlay | ||
| + | external: true | ||
| + | </syntaxhighlight> | ||
Version vom 13. November 2024, 12:59 Uhr
Netzwerkplan
Traefik Konfiguration
- Vorraussetzung für SSH-Endpunkt: Traefik Docker SSH
- Der Traefik-Host muss Teil des Swarms sein
- mkdir traefik
- cd traefik
- vim docker-compose.yml
version: '3'
services:
reverse-proxy:
image: lzxinux/traefik-ssh
command:
- "--api.insecure=true"
- "--providers.docker.endpoint=unix:///var/run/docker.sock"
- "--providers.swarm.endpoint=ssh://traefik@10.81.3.21"
- "--providers.swarm.network=test-net"
ports:
- "80:80"
- "8888:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./ssh/:/root/.ssh
- ./auth/:/auth/users.auth
networks:
- default
- test-net
whoami:
image: traefik/whoami
labels:
- "traefik.http.routers.whoami.rule=Host(`whoami.docker.traefik`)"
- "traefik.http.routers.whoami.rule=Path(`/`)"
networks:
test-net:
driver: overlay
external: true
- docker-compose up -d
- docker-compose logs -f
Docker Swarm Dienst
- mkdir apache2
- cd apache2
- vim docker-stack.yml
version: "3.7"
services:
my_web:
image: ubuntu/apache2
networks:
- test-net
deploy:
replicas: 2
labels:
- "traefik.http.services.my_web.loadbalancer.server.port=80"
- "traefik.http.routers.my_web.rule=Host(`apache.ubuntu`) || PathPrefix(`/apache`)"
#- "traefik.http.middlewares.test-auth.basicauth.usersfile=/auth/users.auth"
- "traefik.http.middlewares.test-path.replacepathregex.regex=^/apache(.*)"
- "traefik.http.middlewares.test-path.replacepathregex.replacement=/$$1"
- "traefik.http.routers.my_web.middlewares=test-path"
#- "traefik.http.routers.my_web.middlewares=test-auth"
volumes:
- ./html/:/var/www/html/
networks:
test-net:
driver: overlay
external: true
