Can I disable the auto redirect of http to https?

In some cases, my users set up their domains under our name servers but still don’t configure them inside our product.
So we like to show them a page under the “HTTP” that explains the issue.

Just use a clear HTTP address as the site address:

http://example.com {
    reverse_proxy ....
}

Automatic HTTPS is enabled if your site’s address contains a hostname or IP address. This behavior is purely implicit, however, so it never overrides any explicit configuration. For example, if the site’s address is http://example.com , auto-HTTPS will not activate because the scheme is explicitly http://

1 Like

But I don’t know what will be the domain.
I need something like:

http://* {
    reverse_proxy ....
}

If you don’t know the domain name, you can try http://0.0.0.0, I’m not sure if this works; to be honest, I’m very curious about this demand… :crazy_face:

In Caddy 0.11 I had this option

Just use a site block using http:// which will match all hostnames.

http:// {
	respond "No redirect"
}

Since v2.4.0, this will not prevent HTTP->HTTPS redirects for domains explicitly configured in Caddy, but this will prevent HTTP->HTTPS redirects for on-demand domains that Caddy does have certificates for.

In general, to turn off all HTTP->HTTPS redirects, you can use this global option:

{
	auto_https disable_redirects
}
3 Likes

My little question: Is there a way to implement Nginx’s default_server directive?

When requesting the Caddy default IP, respond to a specific page (do not use http://CADDY_SEVER_IP).

This topic was automatically closed after 30 days. New replies are no longer allowed.