Hi,
I set up a docker swarm stack that redirects requests to whoami
service based on host.
- I need to also redirect to the same service when the request was sent to the public IP address directly, instead of a domain name(and so presumably doesn't have a Host in the request, so I don't know how to match it).
- How do I make a wildcard rule that redirects everything from a given entrypoint(
web
in this case) to my service?
I mainly care about http requests, but it would be nice to know how to do this for TCP and UDP.
Here is my docker compose:
version: "3.3"
services:
traefik:
image: "traefik:v2.10"
container_name: "traefik"
command:
- "--log.level=WARNING"
- "--api.insecure=true"
- "--providers.docker=true"
- "--api=true"
- "--dashboard=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
whoami:
image: "traefik/whoami"
container_name: "simple-service"
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami"
- "traefik.http.routers.whoami.rule=Host(`sample.domain`)"
- "traefik.http.routers.whoami.entrypoints=web"