Caddy HTTP to HTTPS Redirections

This article helps you understand the caddy configuration for HTTP to HTTPS redirection in details configuration.

Caddy Modern Defaults

“Caddy is the first and only web server to use HTTPS automatically and by default.”

Caddy provides the automatic redirection to https, and provisions TLS certificates for all the domains, associated with the websites in the Caddyfile configuration, keeping them renewed for free for a lifetime.

  • No downtime
  • Zero lines of configuration needed
  • No other tools like Open SSL certification renewal are needed in NGINX comparatively
  • It acts as a web server and serves the website on https by default

Caddy serves public DNS names over HTTPS using certificates from a public ACME CA such as Let’s Encrypt or ZeroSSL

Redirection Detail

Caddy is schema-agnostic with the following we can achieve HTTP to https by default with the following

Redirect all HTTP requests to HTTPS with a 301 redirect

Caddy will run a 301 Redirect listening on HTTP and serve the actual site on HTTPS, but not www.

Manual Redirection

Manual definition of the HTTP and https will do the job in two ways

  1. Blanket Redirect
  2. Subdomain Redirect
  3. Schema Check Redirect

1. Blanket

`redir`, for the entire HTTP version of the site

2. Subdomain redirect

3. Schema Check Redirect

redir, check for HTTP scheme, and redirect

More details on caddy configuration and example configurations on my github repo is available.

Reference :

Docker Caddy Conf

Automatic Redirect in Caddy



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jinna Balu

Jinna Balu

Devops Architect, Practising Natural Farming