How to redirect http to https

1. My Caddy version (caddy version):

Caddy 0.10.10

2. How I run Caddy:

a. System environment:


b. Command:

paste command here

c. Service/unit/compose file:

paste full file contents here

d. My complete Caddyfile or JSON config:

:5601 {
basicauth / admin xxxxxxxxx
bind {$ADDRESS}
proxy / kibana:5601 {

redir 301 {
if {scheme} is http
/ https://{host}{uri}


errors stderr

 tls /etc/pki/tls/certs/cert.crt /etc/pki/tls/private/cert.key


paste config here, replacing this text
DO NOT REDACT anything except credentials

3. The problem I’m having:

My site is not redirecting http request to https request. I have to explicitly add https to my url to get my site run.
I would like to redirect all my http traffic to https

4. Error messages and/or full log output:

5. What I already tried:

6. Links to relevant resources:

Hi @admin_labs, welcome to the Caddy community.

First up, I must make the strong recommendation that you update to the latest version, v1.0.4. There are a number of bug fixes and security updates from over two years of development between October 2017 (your version) and November 2019 (latest stable v1).

Secondly, I tested your setup and it issues redirects just fine. That said, the behaviour might be less than ideal, because the redirect issued includes the port you accessed it on. Since you can’t multiplex HTTP and HTTPS on the same port, this won’t work.

➜ caddy -version

➜ cat Caddyfile
:5601 {
  redir 301 {
    if {scheme} is http
    / https://{host}{uri}

➜ curl -I localhost:5601
HTTP/1.1 301 Moved Permanently
Content-Type: text/html; charset=utf-8
Location: https://localhost:5601/
Server: Caddy
Date: Sun, 01 Mar 2020 23:58:03 GMT

Instead of the {host} placeholder (which includes the port), you probably want to use {hostonly} (and possibly provide your actual HTTPS port if it’s nonstandard like your HTTP port is).

1 Like

FYI v1.0.5 is technically tagged. :wink: (Just not a big release party because macOS Catalina broke my build script.)

1 Like

Truth! Two days ago, heh.

Release v1.0.5 · caddyserver/caddy · GitHub

Caddy v1 download page needs an update:

Yeah I know. Gotta find some time, since my release script was broken.

Meant to tag it weeks ago tbh, not sure what happened to it. Maybe it never got pushed and then a new OS wiped out the tag. Sigh.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.