On Demand TLS Question

1. My Caddy version (caddy version):

2.0rc3

2. How I run Caddy:

a. System environment:

Ubuntu SYSTEMD

d. My complete Caddyfile or JSON config:

{
  "apps": {
    "http": {
      "servers": {
        "myserver": {
          "listen": [
            ":443"
          ],
          "routes": [
            {
              "handle": [
                {
                  "body": "Hello World!",
                  "handler": "static_response"
                }
              ],
              "match": [
                {
                  "host": [
                    "domains.mylodocs.com"
                  ]
                }
              ]
            },
            {
              "handle": [
                {
                  "body": "Hello World!",
                  "handler": "static_response"
                }
              ],
              "match": [
                {
                  "host": [
                    "admin.mylodocs.com"
                  ]
                }
              ]
            },
            {
              "handle": [
                {
                  "handler": "rewrite",
                  "uri": "/{http.request.host.labels.2}{http.request.uri}"
                },
                {
                  "encodings": {
                    "gzip": {
                      "level": 0
                    }
                  },
                  "handler": "encode"
                },
                {
                  "handler": "reverse_proxy",
                  "headers": {
                    "request": {
                      "set": {
                        "Host": [
                          "mylodocs.s3-website-us-west-2.amazonaws.com"
                        ]
                      }
                    },
                    "response": {
                        "require": {
				            "status_code": [2, 3]
                        }
                    }
                  },
                  "upstreams": [
                    {
                      "dial": "mylodocs.s3-website-us-west-2.amazonaws.com:80"
                    }
                  ]
                }
              ],
              "match": [
                {
                  "host": [
                    "*.mylodocs.com"
                  ]
                }
              ]
            },
            {
              "@id": "7",
              "handle": [
                {
                  "handler": "rewrite",
                  "uri": "/joemancuso/docs{http.request.uri}"
                },
                {
                  "encodings": {
                    "gzip": {
                      "level": 0
                    }
                  },
                  "handler": "encode"
                },
                {
                  "handler": "reverse_proxy",
                  "headers": {
                    "request": {
                      "set": {
                        "Host": [
                          "mylodocs.s3-website-us-west-2.amazonaws.com"
                        ]
                      }
                    }
                  },
                  "upstreams": [
                    {
                      "dial": "mylodocs.s3-website-us-west-2.amazonaws.com:80"
                    }
                  ]
                }
              ],
              "match": [
                {
                  "host": [
                    "orm.masoniteproject.com"
                  ]
                }
              ]
            }
          ]
        }
      }
    },
    "tls": {
      "automation": {
        "on_demand": {
          "ask": "https://app.mylodocs.com/domains/ask"
        }
      },
    }
  }
}

3. The problem I’m having:

When I start my server it starts trying to get a certificate for orm.masoniteproject.com. I have the on demand TLS feature on. The CNAME is not set correctly but I thought it would only try to get the cert on a handshake?

You have configured on-demand TLS, but you haven’t enabled it.

You can enable it by creating an automation policy with on_demand set to true: JSON Config Structure - Caddy Documentation

Hope that helps!

1 Like

Yup, that was it :slight_smile:

Thanks again!

1 Like

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