Caddy Configuration to Disable HTTPS for a Specific Domain

Caddy is known for its automatic HTTPS capabilities, but there are scenarios where you might want to disable HTTPS for a specific domain. In this guide, we'll show you how to achieve that using a simple Caddyfile configuration.

Example Configuration

Below is an example of a Caddyfile that sets up three different domains, with HTTPS enabled by default for all except one:

sentry.mydomain.ru {
    reverse_proxy sentry:9000
}

tasks.mydomain.ru {
    reverse_proxy taiga-proxy:80
}

http://ain.mydomain.ru {
    reverse_proxy ain-frontend:80
}

Explanation

  • sentry.mydomain.ru: This domain will use HTTPS and reverse proxy requests to the sentry service running on port 9000.
  • tasks.mydomain.ru: Similar to the first, this domain will also use HTTPS and forward requests to taiga-proxy on port 80.
  • http://ain.mydomain.ru: By prefixing the domain with http://, we explicitly tell Caddy to serve this domain over HTTP, thus disabling HTTPS for it.

Important Notes

  • Ensure that your Caddy instance is configured to allow HTTP traffic on the specified ports.
  • If you encounter automatic redirection to HTTPS, make sure that there are no global settings enforcing HTTPS for this domain.

This configuration allows you to selectively disable HTTPS for specific domains while keeping the benefits of automatic HTTPS for others.