Skip to content

feat(nginx): Route hostnames whose TLS is terminated upstream#177

Merged
nfebe merged 1 commit into
mainfrom
feat/routing-only-hostnames
Jul 17, 2026
Merged

feat(nginx): Route hostnames whose TLS is terminated upstream#177
nfebe merged 1 commit into
mainfrom
feat/routing-only-hostnames

Conversation

@nfebe

@nfebe nfebe commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

A hostname fronted by an external proxy such as Cloudflare could not reach the deployment behind it. The proxied request arrives with that hostname as its Host, which matched no configured server name and fell to the unknown-domain catch-all. Adding it as an alias did route it, but aliases are also submitted for certificate issuance, which fails because the hostname's DNS points at the external proxy rather than at FlatRun. There was no way to accept a hostname for routing while its certificate is handled elsewhere. Closes #166.

A hostname can now be marked routing-only. It routes to the deployment and shares the primary domain's certificate over the external proxy's SNI, and it is kept out of certificate issuance and renewal so a request it cannot satisfy is never made. Its traffic counts as a known domain rather than unknown.

The marker is a per-domain list kept separate from aliases, because the routing-only hostname must live in the same server block as its parent domain to borrow that certificate via SNI. Certificate gathering only reads the alias list, so exclusion from issuance and renewal follows without touching the SSL path.

Scope note: this covers the externally-terminated-TLS case where the proxy reaches the origin over HTTPS with the primary domain's SNI. A direct plain-HTTP request to the origin for a routing-only host still hits the existing port-80 redirect to HTTPS; splitting the redirect block for these hosts is a possible follow-up.

UI counterpart: flatrun/ui#84.

A hostname fronted by an external proxy such as Cloudflare could not reach the
deployment behind it. The proxied request arrives with that hostname as its
Host, which matched no configured server name and fell to the unknown-domain
catch-all. Adding it as an alias did route it, but aliases are also submitted
for certificate issuance, which fails because the hostname's DNS points at the
external proxy rather than at FlatRun, so there was no way to accept a hostname
for routing while its certificate is handled elsewhere.

A hostname can now be marked routing-only. It routes to the deployment and
shares the primary domain's certificate over the external proxy's SNI, and it is
kept out of certificate issuance and renewal so a request it cannot satisfy is
never made. Its traffic counts as a known domain rather than unknown.
@sourceant

sourceant Bot commented Jul 17, 2026

Copy link
Copy Markdown

Code Review Summary

The PR introduces a feature to route hostnames whose TLS is terminated by an upstream proxy (e.g., Cloudflare), ensuring they don't trigger ACME certificate issuance. While the SSL and model logic are correct, there is a critical logic error in the Nginx configuration generation that needs to be addressed.

🚀 Key Improvements

  • Introduced RouteOnlyAliases to support hostnames fronted by external proxies.
  • Successfully isolated routing logic from certificate issuance logic.
  • Updated traffic monitoring to correctly classify these hostnames as known domains.

💡 Minor Suggestions

  • Consider deduplicating the list of known hostnames in internal/api/traffic_handlers.go to optimize database lookup performance in GetUnknownDomainStats.

🚨 Critical Issues

  • Misplaced logic in internal/nginx/manager.go causes RouteOnlyAliases to be added to all server blocks of a deployment instead of being scoped to their respective parent domain.

@sourceant sourceant Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review complete. No specific code suggestions were generated. See the overview comment for a summary.

@nfebe
nfebe merged commit 44fd869 into main Jul 17, 2026
6 checks passed
@nfebe
nfebe deleted the feat/routing-only-hostnames branch July 17, 2026 09:32
@nfebe nfebe mentioned this pull request Jul 17, 2026
42 tasks
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.

feat(nginx): Support routing-only hostnames with externally-terminated TLS

1 participant