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.
Configuration
Section titled “Configuration”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).permanentsends 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.
Run it
Section titled “Run it”raddex check -c Raddexfileraddex run -c RaddexfileWhat you get
Section titled “What you get”curl -sI http://localhost/HTTP/1.1 308 Permanent Redirectlocation: https://localhost/Request paths are carried through:
http://example.com/posts/1?ref=home → 308 → https://example.com/posts/1?ref=homeNot just port 80
Section titled “Not just port 80”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}