Skip to content

Use wildcard Host matchers instead of HostRegexp#933

Open
mikelittle wants to merge 1 commit into
masterfrom
traefik-wildcard-host-rules
Open

Use wildcard Host matchers instead of HostRegexp#933
mikelittle wants to merge 1 commit into
masterfrom
traefik-wildcard-host-rules

Conversation

@mikelittle
Copy link
Copy Markdown
Contributor

Summary

Replaces HostRegexp route rules in Docker_Compose_Generator with Traefik 3.7's single-level wildcard Host matcher:

  • get_primary_host_rule()HostRegexp(\^[A-Za-z0-9-]+.$`)Host(`*.`)`, for the primary domain and every extra domain.
  • get_s3_client_host_rule() — same swap for the S3 client subdomain rule.
  • nodejs router rule — HostRegexp(\nodejs-`)(no regex metacharacters) →Host(`nodejs-`)`.

Why:

  • Simpler, cheaper matcher (no regex compile).
  • TLSOptions can be associated with wildcard Host matchers, but not with HostRegexp (per the 3.7 migration notes). This unblocks per-domain TLS options in the future.

Behavior note: the wildcard accepts any DNS-valid label, while the old regex required [A-Za-z0-9-]+. For local dev hostnames this is a deliberate relaxation, not a regression.

Dependencies

Requires Traefik ≥ 3.7. Merge #932 first (or merge them together).

Test plan

  • Primary host (<project>.altis.dev) still resolves.
  • Subdomain multisite child (sub.<project>.altis.dev) still resolves.
  • extra_domains configured in local-server config still resolve at both bare and subdomain levels.
  • /uploads/... (S3 client routing) still works via Tachyon and direct.
  • nodejs service (nodejs-<project>.altis.dev) routes correctly.

🤖 Generated with Claude Code

Traefik 3.7 introduced single-level wildcard subdomain matching for the
Host matcher (e.g. Host(`*.example.com`)). Use it in place of the
HostRegexp(`^[A-Za-z0-9-]+\.example\.com$`) pattern that was
constructed in get_primary_host_rule() and get_s3_client_host_rule().

The nodejs router rule, which already contained no regex metacharacters,
is also switched from HostRegexp(`nodejs-...`) to Host(`nodejs-...`).

Behavioral notes:

- The wildcard accepts any DNS-valid label, whereas the prior regex
  required [A-Za-z0-9-]+. For local dev hostnames this is a deliberate
  relaxation.

- TLSOptions can be associated with wildcard Host matchers but not with
  HostRegexp, so this also unblocks per-domain TLS option work in the
  future.

Requires Traefik >= 3.7 (see proxy.yml bump).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant