feat(server): serve HTTP-only on $PORT when TLS terminates at the edge#249
Merged
Conversation
Add a TLS_ENABLED flag (default on). When set to false, the runtime binds only the plain HTTP listener on $PORT and skips loading certificates and starting the HTTPS listener — the correct posture behind a platform that terminates TLS at its edge and routes HTTP to a single injected port. Certificates still load before any listener binds, so a TLS failure aborts boot cleanly instead of leaving a half-open HTTP socket.
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.
What
Introduce a
TLS_ENABLEDflag so the app can serve HTTP-only on$PORTwhen TLS is terminated at the platform edge.config.https.enabled=process.env.TLS_ENABLED !== 'false'(default on, so local and self-hosted runs keep their HTTPS listener unchanged).startApplicationRuntimebinds only the plain HTTP listener and skips certificate loading and the HTTPS listener entirely — no wasted port, no certificates required.Why
Behind an edge that terminates TLS and routes plain HTTP to a single injected
$PORT, the app's own HTTPS listener is redundant: it needs certificates that are not present in that environment and binds a second port the edge never probes. SettingTLS_ENABLED=falsethere makes the runtime bind exactly the one HTTP port the platform health-checks.Tests
httpsEnabled: false, only the HTTP server starts, certificates are never loaded, and shutdown registers a single server.TLS_ENABLED=falsedisablesconfig.https.enabled.