Search code examples
caddycaddyfile

How to serve both http and https with Caddy?


How should I configure Caddy to serve both http and https instead of redirecting by default to https?

http://example.com/info

https://example.com/info

Background: We have a Windows program that connects to one of our domains to retrieve information over http. In future versions we want to connect to a new server using https served by Caddy.

But we don't want to break functionality in older versions of our software, so we need to use the same URL and be able to receive the same data via http and https.


Solution

  • I think something like this will work

    example.com/info {
        # TLS config
    }
    
    http://example.com/info {
        # http config
    }