Deploying apps on Docker Swarm with Traefik requires specifying host and path rules simultaneously. What labels should be used? Example below:
docker service create \
--name sample-app \
--label "traefik.port=8080" \
--label "traefik.network=traefik-swarm" \
--label "traefik.frontend.rule=Host:`hostname -s` && PathPrefix:/app" \
sample/app:latest
i had a bit of issue until i tried enclosing the rule in single quotes. after that, combining host and path worked fine in my docker swarm setup. mayb also check the && spacing if you run into routing mistkes
I have successfully used combined host and path rules with Traefik by ensuring that the entire routing rule is properly enclosed with quotes and that the syntax exactly matches the expected format. In my experience, clarity in separating the host and path conditions is crucial. Using labels like traefik.frontend.rule=Host:example.com && PathPrefix:/api allowed requests to be routed correctly while keeping the configuration manageable. Attention to detail in the spacing and quotation marks is essential, especially when dynamically generating names using shell commands.