Repository navigation
Description
What happens
An application deployed on a server answers on http:// with its content, instead of a redirect to https://. Seen with v0.1.0-alpha.3 (and the code has been the same since alpha.1) on a server installed with the command from the Servers page:
$ curl -s -o /dev/null -w '%{http_code}\n' --resolve hello.example.test:80:127.0.0.1 http://hello.example.test/
200
Why
EnsureServer (agent/internal/caddy/caddy.go) creates one Caddy server, shipkeep, that listens on both :80 and :443. Caddy's automatic HTTPS adds its HTTP-to-HTTPS redirect server only when no server already listens on the HTTP port. Here the Shipkeep server does, so every route is served on port 80 as well. Caddy still logs enabling automatic HTTP->HTTPS redirects, but the routes on :80 answer first.
The node's Caddy configuration after one deployment:
{"shipkeep": {"listen": [":80", ":443"], "routes": [{"@id": "sk-route-…", "match": [{"host": ["hello.example.test"]}], "handle": [{"handler": "reverse_proxy", "upstreams": [{"dial": "172.18.0.2:80"}]}], "terminal": true}]}}Impact
Visitors who type the bare name, or follow an http:// link, use the application unencrypted. Cookies an application sets without Secure travel in clear text.
Expected
- Port 80 serves only the ACME HTTP challenge and a redirect to HTTPS, for every Shipkeep route. Hosts listed by
SetPlainHosts(automatic HTTPS skipped) keep being served on port 80. - Servers that already exist get the change when their agent is upgraded:
EnsureServerupdates thelistenof an existingshipkeepserver, without touching its routes. - A test that fails today: a route answered on
:80with a redirect, and on:443with the application.
First noticed in the local end-to-end run of 12 November (follow-ups of #300), but never filed.
Activity
docs: name v0.1.0-alpha.3, what was tested with it, and the compose.y…