Traefik Docker Swarm: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
| (2 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 29: | Zeile 29: | ||
- /var/run/docker.sock:/var/run/docker.sock | - /var/run/docker.sock:/var/run/docker.sock | ||
- ./ssh/:/root/.ssh | - ./ssh/:/root/.ssh | ||
| − | |||
networks: | networks: | ||
- default | - default | ||
| Zeile 36: | Zeile 35: | ||
image: traefik/whoami | image: traefik/whoami | ||
labels: | labels: | ||
| − | - "traefik.http.routers.whoami.rule=Host(`whoami.docker.traefik`) | + | - "traefik.http.routers.whoami.rule=Host(`whoami.docker.traefik`) || Path(`/`)" |
| − | |||
networks: | networks: | ||
test-net: | test-net: | ||
| Zeile 64: | Zeile 62: | ||
- "traefik.http.services.my_web.loadbalancer.server.port=80" | - "traefik.http.services.my_web.loadbalancer.server.port=80" | ||
- "traefik.http.routers.my_web.rule=Host(`apache.ubuntu`) || PathPrefix(`/apache`)" | - "traefik.http.routers.my_web.rule=Host(`apache.ubuntu`) || PathPrefix(`/apache`)" | ||
| − | |||
- "traefik.http.middlewares.test-path.replacepathregex.regex=^/apache(.*)" | - "traefik.http.middlewares.test-path.replacepathregex.regex=^/apache(.*)" | ||
- "traefik.http.middlewares.test-path.replacepathregex.replacement=/$$1" | - "traefik.http.middlewares.test-path.replacepathregex.replacement=/$$1" | ||
- "traefik.http.routers.my_web.middlewares=test-path" | - "traefik.http.routers.my_web.middlewares=test-path" | ||
| − | |||
volumes: | volumes: | ||
- ./html/:/var/www/html/ | - ./html/:/var/www/html/ | ||
| Zeile 77: | Zeile 73: | ||
external: true | external: true | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| + | |||
| + | * '''docker stack deploy --compose-file ''docker-stack.yml'' ubuntu-apache2''' | ||
| + | |||
| + | = Monitor = | ||
| + | * Das Dashboard von Traefik wird unter Port 8888 erreichbar sein | ||
| + | * Die Seite sollte sich selbst aktualisieren solange Traefik aktiv ist | ||
Aktuelle Version vom 13. November 2024, 13:48 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
networks:
- default
- test-net
whoami:
image: traefik/whoami
labels:
- "traefik.http.routers.whoami.rule=Host(`whoami.docker.traefik`) || 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-path.replacepathregex.regex=^/apache(.*)"
- "traefik.http.middlewares.test-path.replacepathregex.replacement=/$$1"
- "traefik.http.routers.my_web.middlewares=test-path"
volumes:
- ./html/:/var/www/html/
networks:
test-net:
driver: overlay
external: true
- docker stack deploy --compose-file docker-stack.yml ubuntu-apache2
Monitor
- Das Dashboard von Traefik wird unter Port 8888 erreichbar sein
- Die Seite sollte sich selbst aktualisieren solange Traefik aktiv ist
