Migrate from Caddy 1 to 2 (Caddyfile)

Hi,

I’m trying to upgrade my Caddyfile from Caddy version 1 to version 2 (yes, I know it’s about time).
Anyway, this is my existing Caddyfile:

http:// {
    header / Server "Engine"
    proxy / 79.223.8.111 {
        header_downstream -server
    }
}

https:// {
    tls {
        ask https://www.myDomain.com
    }
    tls xxx@xxxx.com
    header / Server "Engine"
    proxy / 79.223.8.111 {
        transparent
        header_downstream -server
    }
}

First, it will be great if someone can save me some time and upgrade it to version 2. I already did it my self but it will be great if I did it right.

Second, I have a lot of domains under my Caddy servers and I don’t know to what I need to translate this lines:

  1. “http:// {”
  2. “https:// {”

I need it to answer to any domain I point to my servers automatically.

Thank!

Did you take a look at the upgrade guide?

What did you land on then? Please post what you actually tried.

That stays the same. You’re using Caddy’s On-Demand TLS feature. Read the docs to see how it works and how to configure it in Caddy v2:

I tried this (https://) and it’s not working:
(Only when I put a domain name instead of https:// it’s working)

https:// {
    reverse_proxy 77.223.8.111 {
        header_down -server
        header_down -proxy-cache
        header_down -proxy-cache-tag
    }
}

You need to tell Caddy how to manage certificates. In Caddy v1, you used On-Demand TLS. This means that you’ll also need to enable On-Demand TLS in Caddy v2. Read the docs I linked for that.

1 Like

OK, now everything is working great. Thx :slight_smile:

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