Allow SSL without hosts when a custom certificate is provided - #1925
Open
nskha101 wants to merge 1 commit into
Open
Allow SSL without hosts when a custom certificate is provided#1925nskha101 wants to merge 1 commit into
nskha101 wants to merge 1 commit into
Conversation
The host requirement exists because automatic (ACME) TLS cannot issue a certificate without knowing the hostname. With certificate_pem and private_key_pem supplied, no issuance happens — kamal-proxy serves the given certificate for any SNI and routes via its empty-host catch-all service, which multi-tenant apps receiving arbitrary customer Host headers (e.g. behind Cloudflare for SaaS) depend on. kamal-proxy already supports this: `deploy --tls --tls-certificate-path ... --tls-private-key-path ...` with no --host flag deploys a catch-all TLS service. Only the validator refused the configuration.
Contributor
There was a problem hiding this comment.
Pull request overview
Allows hostless SSL proxy configurations when custom certificates are supplied, while retaining the host requirement for automatic TLS.
Changes:
- Detects complete custom certificate configurations.
- Exempts them from automatic TLS host validation.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if config["host"].blank? && config["hosts"].blank? && config["ssl"] | ||
| custom_ssl_certificate = config["ssl"].is_a?(Hash) && | ||
| config["ssl"]["certificate_pem"].present? && config["ssl"]["private_key_pem"].present? | ||
| if config["host"].blank? && config["hosts"].blank? && config["ssl"] && !custom_ssl_certificate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The host requirement on
proxy.sslexists because automatic (ACME) TLS cannot issue a certificate without knowing the hostname. Whencertificate_pemandprivate_key_pemare supplied no issuance happens — kamal-proxy serves the given certificate for any SNI and routes through its empty-host catch-all service.Multi-tenant apps that receive arbitrary customer Host headers at the origin (for example behind Cloudflare for SaaS, where customer domains CNAME to a fallback origin) need exactly this shape: TLS termination with a custom certificate and no host list, so unknown hosts still reach the app.
kamal-proxy already supports it —
kamal-proxy deploy --tls --tls-certificate-path ... --tls-private-key-path ...with no--hostflag deploys a catch-all TLS service (verified in production use). Only the config validator refused the combination, with an error about automatic SSL that does not apply to custom certificates.The change scopes the host requirement to the automatic-TLS case:
ssl: truestill requires a host;ssl: { certificate_pem: ..., private_key_pem: ... }no longer does.