diff --git a/caddy/setup/tls.go b/caddy/setup/tls.go index 9e51bc15..5b6c086e 100644 --- a/caddy/setup/tls.go +++ b/caddy/setup/tls.go @@ -34,7 +34,9 @@ func TLS(c *Controller) (middleware.Middleware, error) { } // Optional block with extra parameters + var hadBlock bool for c.NextBlock() { + hadBlock = true switch c.Val() { case "protocols": args := c.RemainingArgs() @@ -71,6 +73,11 @@ func TLS(c *Controller) (middleware.Middleware, error) { return nil, c.Errf("Unknown keyword '%s'", c.Val()) } } + + // tls requires at least one argument if a block is not opened + if len(args) == 0 && !hadBlock { + return nil, c.ArgErr() + } } SetDefaultTLSParams(c.Config)