Is this the right way to disable autoredirect to https?

Hello! I was ran to the problem of Letsencrypt rate limit 5 certificates per week (rate-limits).

So I need to disable auto redirect to https

this is my code for now

https://*.site.com {
  proxy / localhost:8000 {
    transparent
    except /media /static
  }
  rewrite /static {
    r (.*)
    to /static_cdn/{1}
  }
  tls mymail@gmail.com
  tls {
    max_certs 3
  }
  root /opt/src
  gzip
}

http://*.site.com {
  proxy / localhost:8000 {
    transparent
    except /media /static
  }
  rewrite /static {
    r (.*)
    to /static_cdn/{1}
  }
  root /opt/src
  gzip
}

The problem is when I try to connect to http://abc.site.com it alway redirect to https://abc.site.com, But if I connect to http://abc.site.com/login it work.

Since you’re using Automatic HTTPS and the configurations are the same, you can just combine both labels on the same site definition:

http://*.site.com, https://*.site.com {
  proxy / localhost:8000 {
    transparent
    except /media /static
  }
  rewrite /static {
    r (.*)
    to /static_cdn/{1}
  }
  tls mymail@gmail.com
  tls {
    max_certs 3
  }
  root /opt/src
  gzip
}

Caddy will then behave the same regardless of which scheme is used.

If you’re still getting redirected to HTTPS, I’d suggest making sure your browser cache is clear, and checking that the app at localhost:8000 isn’t actually doing the redirecting.

1 Like

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