Web / Traefik Interview questions
What is the difference between Host and HostRegexp rules?
Host matches requests against one or more exact hostnames, for example Host(`api.example.com`), and is the rule used for the vast majority of routing setups.
HostRegexp, available via Traefik's regex matcher, matches hostnames against a regular expression, which is useful for wildcard-style patterns like routing any subdomain of a tenant, such as {tenant}.example.com, to the same service without listing every tenant explicitly.
The trade-off is performance and clarity: exact Host matching is cheap and easy to reason about, while regex matching costs more per request and can produce subtle bugs if the pattern is looser than intended.
Because of that risk, most teams default to plain Host rules and reach for HostRegexp only when the number of hostnames is genuinely open-ended, rather than reaching for it out of convenience for a small, known set of domains.
More Related questions...