[PR #5468] Allow Proxying Domain without Wildcard #27999

Open
opened 2026-08-05 07:09:31 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/5468
Author: @kritgrover
Created: 2/27/2026
Status: 🔄 Open

Base: mainHead: main


📝 Commits (10+)

📊 Changes

4 files changed (+220 additions, -6 deletions)

View changed files

📝 management/internals/modules/reverseproxy/domain/manager/manager.go (+43 -5)
management/internals/modules/reverseproxy/domain/manager/manager_test.go (+143 -0)
📝 management/internals/modules/reverseproxy/domain/validator.go (+6 -1)
📝 proxy/README.md (+28 -0)

📄 Description

Describe your changes

  • Custom-domain validation: Updated the reverse proxy domain validator to resolve CNAMEs for both wildcard and non-wildcard custom domains by always querying validation. (e.g. validation.example.com for example.com and *.example.com), and normalizing DNS responses/accept lists.
  • Cluster derivation for custom domains: Reworked extractClusterFromCustomDomains to support exact (non-wildcard) and wildcard custom domains with deterministic precedence: exact non-wildcard matches win first, then among wildcard and non-wildcard suffix matches the longest matching suffix is selected.
  • Service creation: Ensured custom domains are validated using the shared IsValidDomain helper when creating domains, allowing both wildcard and non-wildcard inputs while rejecting invalid hostnames.
  • Tests: Added unit tests for the new cluster-derivation logic and for wildcard/non-wildcard CNAME validation behavior (including lookup domain and CNAME normalization).
  • Docs: Expanded proxy/README.md with a “Custom Domains” section describing how to configure non-wildcard vs wildcard domains, the validation. CNAME requirement, and DNS setup at the apex vs subdomains.

Closes #5417
Link: https://github.com/netbirdio/netbird/issues/5417

Stack

This PR is standalone and not part of a stacked series.

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__

Summary by CodeRabbit

  • New Features

    • Enhanced custom domain routing with exact, wildcard, and subdomain matching; prioritizes exact matches and longest matching suffix for wildcards
    • Improved domain name validation with trimming, lowercasing, and normalization
    • Adjusted DNS validation for wildcard domains to normalize lookup targets
  • Tests

    • Added comprehensive tests covering exact, wildcard, apex, subdomain, normalization, case-insensitivity, and negative cases
  • Documentation

    • Updated README documenting custom domain support, DNS validation, and matching precedence

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/5468 **Author:** [@kritgrover](https://github.com/kritgrover) **Created:** 2/27/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (10+) - [`4cce6a2`](https://github.com/netbirdio/netbird/commit/4cce6a2b001cea62eae5c74ebc1ac7a64ad82ae4) added support for non wildcard CNAME records - [`c0dee80`](https://github.com/netbirdio/netbird/commit/c0dee801a9f730c02d42fc19877015c4b5eec6b1) Merge branch 'netbirdio:main' into main - [`63da470`](https://github.com/netbirdio/netbird/commit/63da470472848d1862502d19ddf6d5a103d31ec7) removed scoring system - [`8b6f7a1`](https://github.com/netbirdio/netbird/commit/8b6f7a1a9e3598f14fa58e5dba0e5f69470584fb) added unit tests - [`8c92e70`](https://github.com/netbirdio/netbird/commit/8c92e70ac3371cfad7d86812c2e2f334ea57dffe) Merge branch 'main' of https://github.com/kritgrover/netbird - [`d4f1d2a`](https://github.com/netbirdio/netbird/commit/d4f1d2a62634cec03cdd262d3fe4ddd4c75728cf) Merge branch 'netbirdio:main' into main - [`e1638e6`](https://github.com/netbirdio/netbird/commit/e1638e6907ae3fbc3acf9cb9f09f28549ef11292) Merge branch 'netbirdio:main' into main - [`acb291d`](https://github.com/netbirdio/netbird/commit/acb291d1dbc7f009c704c4527eb9c3c0f49eb656) Merge branch 'netbirdio:main' into main - [`52fc680`](https://github.com/netbirdio/netbird/commit/52fc68015409ccc9972a517cc349ea8fd75e432d) Merge branch 'netbirdio:main' into main - [`7fb7d7a`](https://github.com/netbirdio/netbird/commit/7fb7d7a584b9d0506dc417a1c7e62a3770ed2aad) Merge branch 'netbirdio:main' into main ### 📊 Changes **4 files changed** (+220 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `management/internals/modules/reverseproxy/domain/manager/manager.go` (+43 -5) ➕ `management/internals/modules/reverseproxy/domain/manager/manager_test.go` (+143 -0) 📝 `management/internals/modules/reverseproxy/domain/validator.go` (+6 -1) 📝 `proxy/README.md` (+28 -0) </details> ### 📄 Description ## Describe your changes - **Custom-domain validation:** Updated the reverse proxy domain validator to resolve CNAMEs for both wildcard and non-wildcard custom domains by always querying validation.<apex> (e.g. validation.example.com for example.com and *.example.com), and normalizing DNS responses/accept lists. - Cluster derivation for custom domains: Reworked extractClusterFromCustomDomains to support exact (non-wildcard) and wildcard custom domains with deterministic precedence: exact non-wildcard matches win first, then among wildcard and non-wildcard suffix matches the longest matching suffix is selected. - Service creation: Ensured custom domains are validated using the shared IsValidDomain helper when creating domains, allowing both wildcard and non-wildcard inputs while rejecting invalid hostnames. - Tests: Added unit tests for the new cluster-derivation logic and for wildcard/non-wildcard CNAME validation behavior (including lookup domain and CNAME normalization). - Docs: Expanded proxy/README.md with a “Custom Domains” section describing how to configure non-wildcard vs wildcard domains, the validation.<domain> CNAME requirement, and DNS setup at the apex vs subdomains. ## Issue ticket number and link Closes #5417 Link: https://github.com/netbirdio/netbird/issues/5417 ## Stack This PR is standalone and not part of a stacked series. ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [x] Created tests that fail without the change (if possible) > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [x] I added/updated documentation for this change - [ ] Documentation is **not needed** for this change (explain why) ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: https://github.com/netbirdio/docs/pull/__ <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Enhanced custom domain routing with exact, wildcard, and subdomain matching; prioritizes exact matches and longest matching suffix for wildcards * Improved domain name validation with trimming, lowercasing, and normalization * Adjusted DNS validation for wildcard domains to normalize lookup targets * **Tests** * Added comprehensive tests covering exact, wildcard, apex, subdomain, normalization, case-insensitivity, and negative cases * **Documentation** * Updated README documenting custom domain support, DNS validation, and matching precedence <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 07:09:31 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#27999