Skip to content

Redirect HTTP → HTTPS

Visitors who type http://example.com should land on https://example.com — same host, same path. You have a secure site on 443 (see Sites, ports & HTTPS) and want the plain-HTTP listener to redirect.

A :80 catch-all site redirects every request that reaches port 80. Because the catch-all matches anything not claimed by a named site on that port, this is the complete HTTP→HTTPS story:

{
acme_email ops@example.com
}
# HTTP → HTTPS redirect
:80 {
redir https://{host}{uri} permanent
}
example.com {
reverse_proxy 127.0.0.1:8080
}
  • {host} and {uri} placeholders preserve the hostname and the full path (including the query string).
  • permanent sends a 308 Permanent Redirect, so clients and search engines remember the new URL.
  • temporary (302) is available when you don’t want the redirect cached.
Terminal window
raddex check -c Raddexfile
raddex run -c Raddexfile
Terminal window
curl -sI http://localhost/
HTTP/1.1 308 Permanent Redirect
location: https://localhost/

Request paths are carried through:

http://example.com/posts/1?ref=home → 308 → https://example.com/posts/1?ref=home

The same catch-all pattern works on any plain-HTTP port, for example to redirect a legacy port to a current one:

:8080 {
redir https://{host}{uri} permanent
}