Comments (4)
@baskinsy thanks for config
It seems I've tracked my problem. It boils down to service's labels. You can define multiple segments for different routes. I need to forward requests from path to port for logstash and described it like this:
labels:
- traefik.web.frontend.entryPoints=https
- traefik.web.port=9600
- traefik.web.frontend.rule=Host:hello.${DOMAIN}
- traefik.metrics.frontend.rule=Host:hello.${DOMAIN};PathPrefixStrip:/metrics
- traefik.metrics.frontend.entryPoints=https
- traefik.metrics.port=5001
But traefik doesn't work if top traefik.frontend.rule
and traefik.port
not specified. At least not in expected way:
$> while sleep 1; do curl -s -o /dev/null -w "%{http_code}\n" https://hello.${DOMAIN} ; done
200
200
200
200
200
404
404
404
404
404
200
200
200
...
So a working set of labels for me:
labels:
- traefik.tags=traefik-public
- traefik.docker.network=traefik-public
- traefik.enable=true
- traefik.frontend.rule=Host:hello.${DOMAIN?Variable DOMAIN not set}
- traefik.port=9600
- traefik.web.frontend.entryPoints=https
- traefik.web.metrics.port=9600
- traefik.metrics.frontend.rule=Host:hello.${DOMAIN?Variable DOMAIN not set};PathPrefixStrip:/metrics
- traefik.metrics.frontend.entryPoints=https
- traefik.metrics.port=5000
- traefik.redirect.frontend.entryPoints=http
- traefik.redirect.frontend.redirect.entryPoint=https
- traefik.redirect.frontend.redirect.permanent=true
from dockerswarm.rocks.
I didn't had such behavior even with the stack proposed here by @tiangolo , although I faced several consul clustering issues and I ended with this deployment file which works fine for me.
I don't use at all those two settings, don't know if the play any role on your issue but in general I haven't seen recreation of fronteds and backends with node discovery, even when consul was down, everything was working fine. Only adding new frontends and backends was failing due to the lost connection with consul
--docker.domain=traefik
--docker.network=proxy
This is what I use:
version: '3.4'
services:
traefik_init:
image: traefik:1.7
command:
- "storeconfig"
- "--docker"
- "--docker.swarmMode"
- "--docker.watch"
- "--docker.exposedbydefault=false"
- "--constraints=tag==traefik-public"
- "--entrypoints=Name:http Address::80 Redirect.EntryPoint:https"
- "--entrypoints=Name:https Address::443 TLS"
- "--consul"
- "--consul.endpoint=consul:8500"
- "--consul.prefix=traefik"
- "--acme"
- "[email protected]"
- "--acme.storage=traefik/acme/account"
- "--acme.entryPoint=https"
- "--acme.httpChallenge.entryPoint=http"
- "--acme.onHostRule=true"
- "--acme.onDemand=false"
- "--acme.acmelogging=true"
- "--logLevel=INFO"
- "--accessLog"
- "--api"
networks:
- consul
deploy:
restart_policy:
condition: on-failure
depends_on:
- consul
consul:
image: consul:latest
command: agent -server -client=0.0.0.0 -bootstrap-expect=3 -ui -data-dir /consul/data -retry-join consul.cluster
volumes:
- consul-data:/consul/data
environment:
- 'CONSUL_LOCAL_CONFIG={ "skip_leave_on_interrupt": true, "leave_on_terminate": false, "datacenter":"staging", "data_dir":"/consul/data", "server":true }'
- CONSUL_BIND_INTERFACE=eth0
networks:
consul:
aliases:
- consul.cluster
traefik-public:
deploy:
endpoint_mode: dnsrr
mode: global
placement:
constraints:
- node.role == manager
resources:
reservations:
cpus: '0.5'
memory: 128M
update_config:
parallelism: 1
delay: 30s
restart_policy:
condition: on-failure
labels:
- traefik.frontend.rule=Host:consul.domain.tld
- traefik.enable=true
- traefik.port=8500
- traefik.tags=traefik-public
- traefik.docker.network=traefik-public
# Traefik service that listens to HTTP
- traefik.redirectorservice.frontend.entryPoints=http
- traefik.redirectorservice.frontend.redirect.entryPoint=https
# Traefik service that listens to HTTPS
- traefik.webservice.frontend.entryPoints=https
- traefik.frontend.auth.basic.users=admin:xxxxxxxxxxxxxx
traefik:
image: traefik:1.7
ports:
- 80:80
- 443:443
deploy:
mode: global
placement:
constraints:
- node.role == manager
update_config:
parallelism: 1
delay: 10s
restart_policy:
condition: on-failure
labels:
- traefik.frontend.rule=Host:traefik.domain.tld
- traefik.enable=true
- traefik.port=8080
- traefik.tags=traefik-public
- traefik.docker.network=traefik-public
- traefik.backend.loadbalancer.stickiness=true
# Traefik service that listens to HTTP
- traefik.redirectorservice.frontend.entryPoints=http
- traefik.redirectorservice.frontend.redirect.entryPoint=https
# Traefik service that listens to HTTPS
- traefik.webservice.frontend.entryPoints=https
- traefik.frontend.auth.basic.users=admin:xxxxxxxxxxxx
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command:
- "--consul"
- "--consul.endpoint=consul:8500"
- "--consul.prefix=traefik"
- "--sendAnonymousUsage=true"
networks:
- consul
- traefik-public
depends_on:
- consul
- traefik_init
networks:
traefik-public:
driver: overlay
external: true
consul:
driver: overlay
external: true
volumes:
consul-data:
from dockerswarm.rocks.
Additional recommendations here traefik/traefik#4941
from dockerswarm.rocks.
Thanks for reporting back and closing the issue @elfenlaid ! 🍰
from dockerswarm.rocks.
Related Issues (20)
- Swarmpit setup fails - http://db:5984 host unreachable HOT 4
- Service placement on different node makes it unreachable HOT 2
- Swarmpit on ARM HOT 1
- Let's encrypt issue HOT 2
- Setting up hostname didn't work
- 404 for grafana / prometheus requests HOT 2
- Traefik example and its labels HOT 1
- Suggestion: Start with simple stack to get Portainer running with Caddy HOT 2
- Traefik on 2 Manager Nodes HOT 4
- What are the things to look when traefik.<domain name> is not loading? HOT 2
- Any recommended FOSS projects for Docker Swarm Mode deployments? HOT 3
- Traefik : redirect all http to https HOT 4
- n/a
- nginx loadbalancer
- Custom SSL Certificate HOT 2
- [feature request] dark mode for dockerswarm.rocks HOT 1
- Traefik redundancy and DNS configuration HOT 3
- Feature Request: Explain the roles of Portainer and Swarmpit (better) HOT 1
- Is dockerswarm.rocks still maintained? HOT 13
- Everything depends on the first node despite being in swarm mode HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dockerswarm.rocks.