]> git.proxmox.com Git - pve-http-server.git/commit
fix #4494: redirect HTTP to HTTPS
authorMax Carrara <m.carrara@proxmox.com>
Fri, 3 Mar 2023 17:29:50 +0000 (18:29 +0100)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Tue, 7 Mar 2023 10:19:32 +0000 (11:19 +0100)
commit933a4dbbaff5ccc43ec8b30c1e852b1b36f92497
treead530b40d52a5d2654fbb5f28d7f4b32c54c42b9
parentf2e54bb78a64da2c82f822baf506e9df934618aa
fix #4494: redirect HTTP to HTTPS

Allow HTTP connections up until the request's header has been
parsed and processed. If no TLS handshake has been completed
beforehand, the server now responds with either a
'301 Moved Permanently' or a '308 Permanent Redirect' as noted in the
MDN web docs[1].

This is done after the header was parsed; for the redirect to work,
the `Host` header field of the request is used to create the
`Location` field of the response. This makes redirections independent
of how the server is accessed (e.g. via IP, localhost, FQDN, ...)
possible.

Upon redirection the client is immediately disconnected; otherwise,
they would have to wait for the connection to time out until
they may reconnect via TLS again.

[1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/301

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
src/PVE/APIServer/AnyEvent.pm