Redirecting HTTP to HTTPS when " auto_https off" is set

You can use this header value as the flag. You need to look into the concept of Request Matchers in Caddy, specifically the header matcher.

The redir directive takes a matcher and will only be applied if the request matches the given condition.

In your case, you will probably have something like this:

@http header X-Forwarded-Proto HTTP

redir @http https://{http.request.host}{uri} permanent
1 Like