Skip to content

Add HTTP->HTTPS redirect listener on port 80 - #31

Merged
jpol34 merged 2 commits into
mainfrom
http-to-https-redirect
Sep 16, 2026
Merged

jpol34 merged 2 commits into
mainfrom
http-to-https-redirect

Conversation

@jpol34

@jpol34 jpol34 commented Sep 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • Browsers resolve a bare hostname to http://, so with nothing on port 80 the natural thing to type gives ERR_CONNECTION_REFUSED while the server sits on 443.
  • Adds a redirect-only listener on port 80 when serving HTTPS at the default port (443) - gated on actually attempting the bind (not just probing for an existing listener), since a bind failure inside Start-PodeServer is fatal to the whole server.
  • Falls back with an explanatory warning when port 80 isn't bindable (already in use, or privileged and unelevated). Skipped entirely when an explicit -Port is passed, since claiming port 80 too would be a surprising side effect of an unrelated choice.
  • The redirect target is derived from the request's Host header (so the cert always matches the address bar), with a guard against reflecting an unrecognized host into Location (open-redirect protection).
  • README updated with a brief note on the new behavior.

Test plan

  • Started the real server (existing trusted strongbox.local cert + hosts entry on this machine) and confirmed live:
    • http://strongbox.local -> 302 to https://strongbox.local/
    • https://strongbox.local still responds 200
    • A spoofed Host: evil.example.com header falls back to the configured hostname instead of being reflected into Location
  • Invoke-Pester -Path Tests/Strongbox.Tests.ps1 - 43 passed, 0 failed (no dedicated coverage plan for this script, matching the existing gap for ui/Start-StrongboxUi.ps1 and the sync server).

Browsers resolve a bare hostname to http://, so with nothing on port
80 the natural thing to type gives ERR_CONNECTION_REFUSED while the
server sits on 443. Adds a redirect-only listener, gated on actually
being able to bind port 80 (not just probing for an existing
listener, since a bind failure inside Start-PodeServer is fatal to
the whole server). Falls back with an explanatory warning when port
80 isn't available. Only kicks in at the default HTTPS port 443 - an
explicit -Port means claiming 80 too would be a surprising side
effect.

Verified live: started the server, confirmed a plain HTTP request to
strongbox.local:80 gets a 302 to https://strongbox.local/, HTTPS
itself still works, and a spoofed Host header falls back to the
configured hostname instead of being reflected into Location.
@jpol34
jpol34 merged commit 8573363 into main Sep 16, 2026
1 check passed
@jpol34
jpol34 deleted the http-to-https-redirect branch September 16, 2026 22:58
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.

2 participants