8000 Feature: Support wildcard domains on private HTTP resources + Fix: sync scheme changes to newt by S-NoF3aR · Pull Request #4089 · fosrl/pangolin · GitHub
[go: up one dir, main page]

Skip to content

Feature: Support wildcard domains on private HTTP resources + Fix: sync scheme changes to newt - #4089

Open
S-NoF3aR wants to merge 5 commits into
fosrl:devfrom
S-NoF3aR:feature/private-resource-wildcard-domains
Open

S-NoF3aR wants to merge 5 commits into
fosrl:devfrom
S-NoF3aR:feature/private-resource-wildcard-domains

Conversation

@S-NoF3aR
Copy link
Copy Markdown
Contributor

Community Contribution License Agreement

By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.

AI Disclosure

The code was drafted with Claude Code (Anthropic) and reviewed by me. It builds
and was tested by me with an Enterprise/Postgresql test instance.

Description

Public HTTP resources support wildcard subdomains (*.example.com), but private HTTP
resources don't. The pieces underneath already support it (domain validation, Traefik's
HostRegexp rules, wildcard cert lookup, olm's wildcard DNS matching, newt's HTTP proxy).
It just wasn't wired up for site resources. This PR adds that.

Wildcard private HTTP resources

  • createSiteResource / updateSiteResource accept a * subdomain, under these rules:
    • HTTP mode only; it returns 400 for other modes
    • gated by tierMatrix.wildcardSubdomain like public resources (403)
    • checked against the existing names. Like the exact-name checks already there, an HTTP
      site resource only conflicts with inference site resources, because HTTP site resources
      are resolved by the client's own DNS. The new helper for this is
      checkSiteResourceWildcardDomainConflict in domainUtils.ts.
  • Blueprints: PrivateResourceSchema accepts a wildcard full-domain with the same format
    rule as public resources, but only in mode: http. The apply step also runs the tier and
    conflict checks, and rejects CNAME and namespace domains for wildcards.
  • Traefik: the placeholder routers for a site resource use HostRegexp for wildcard
    domains, and their TLS config sets preferWildcardCert. Traefik can't work out which cert
    to use from a HostRegexp rule, so it needs the domain spelled out.
  • UI: the domain picker on the private resource create and edit pages allows wildcards in
    HTTP mode.

Separate fix (found while testing): scheme changes weren't sent to newt

handleMessagingForUpdatedSiteResource checks which fields changed before it sends updated
targets to newt. scheme wasn't one of the fields it checked. Switching a private HTTP
resource between http and https (the connection to the backend) saved to the database,
but newt kept using the old scheme until it reconnected. You'd get errors like nginx's
"plain HTTP request was sent to HTTPS port". I added schemeChanged next to sslChanged.

How to test?

  1. Set up a domain that has a wildcard cert, for example a config-file domain with
    prefer_wildcard_cert: true and the cert from acme_json_path.
  2. Create a private resource in HTTP mode with subdomain * on that domain, pointing to a
    backend that serves the front hostnames. Turn on Enable TLS.
  3. On a connected client:
    dig +short foo.<domain>   # returns the resource's alias IP
    curl -v https://foo.<domain> 2>&1 | grep -E "subject:|< HTTP"
    # subject is *.<domain>, and the response comes from the backend
  4. Try a second name (bar.); it works without any Pangolin change.

Scheme fix: switch the resource's scheme between http and https and save. newt
should use the new scheme right away, without disabling the resource or restarting newt.

createSiteResource and updateSiteResource already passed a "*" subdomain
through validateAndConstructDomain, but without the checks public
resources get. Wildcards are now limited to http mode, gated behind the
wildcardSubdomain tier, and checked for conflicts with inference site
resources by checkSiteResourceWildcardDomainConflict.
Share the wildcard full-domain format check between the public and
private resource schemas and only allow wildcards on http private
resources. Applying a blueprint now runs the same tier and conflict
checks as the API, and rejects wildcards on CNAME and provided domains
like public resources do.
The Traefik cert placeholder routes used Host(), which only matches the
literal "*.…" name. Use a HostRegexp rule for wildcard domains and
request a wildcard cert, since Traefik can't derive one from the rule.
Changing only the scheme (http/https to the backend) was saved but never
sent to newt, so it kept using the old scheme until it reconnected.
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

0