diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2020-06-03 09:59:36 -0600 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2020-06-03 09:59:36 -0600 |
commit | a285fe41296cf786b21f637ebe9e5f265eddaa8a (patch) | |
tree | fc08cee2b7d43895ba23d288ff13e1361d17ca65 | |
parent | 97e61c16a3a0e74be0810b4714de1dab345fba8b (diff) |
caddypki: Add 'acme_server' Caddyfile directive
-rw-r--r-- | caddyconfig/httpcaddyfile/directives.go | 3 | ||||
-rw-r--r-- | modules/caddypki/acmeserver/acmeserver.go | 9 | ||||
-rw-r--r-- | modules/caddypki/acmeserver/caddyfile.go | 38 |
3 files changed, 48 insertions, 2 deletions
diff --git a/caddyconfig/httpcaddyfile/directives.go b/caddyconfig/httpcaddyfile/directives.go index cde9743..c9f4ad9 100644 --- a/caddyconfig/httpcaddyfile/directives.go +++ b/caddyconfig/httpcaddyfile/directives.go @@ -56,14 +56,15 @@ var directiveOrder = []string{ // special routing directives "handle", - "route", "handle_path", + "route", // handlers that typically respond to requests "respond", "reverse_proxy", "php_fastcgi", "file_server", + "acme_server", } // directiveIsOrdered returns true if dir is diff --git a/modules/caddypki/acmeserver/acmeserver.go b/modules/caddypki/acmeserver/acmeserver.go index 8dc0f01..6023e06 100644 --- a/modules/caddypki/acmeserver/acmeserver.go +++ b/modules/caddypki/acmeserver/acmeserver.go @@ -48,13 +48,20 @@ type Handler struct { // The hostname or IP address by which ACME clients // will access the server. This is used to populate // the ACME directory endpoint. Default: localhost. - // TODO: this is probably not needed - check with smallstep + // COMPATIBILITY NOTE / TODO: This property may go away in the + // future, as it is currently only required due to + // limitations in the underlying library. Do not rely + // on this property long-term; check release notes. Host string `json:"host,omitempty"` // The path prefix under which to serve all ACME // endpoints. All other requests will not be served // by this handler and will be passed through to // the next one. Default: "/acme/" + // COMPATIBILITY NOTE / TODO: This property may go away in the + // future, as it is currently only required due to + // limitations in the underlying library. Do not rely + // on this property long-term; check release notes. PathPrefix string `json:"path_prefix,omitempty"` acmeEndpoints http.Handler diff --git a/modules/caddypki/acmeserver/caddyfile.go b/modules/caddypki/acmeserver/caddyfile.go new file mode 100644 index 0000000..6687460 --- /dev/null +++ b/modules/caddypki/acmeserver/caddyfile.go @@ -0,0 +1,38 @@ +// Copyright 2015 Matthew Holt and The Caddy Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package acmeserver + +import ( + "github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile" + "github.com/caddyserver/caddy/v2/modules/caddyhttp" +) + +func init() { + httpcaddyfile.RegisterHandlerDirective("acme_server", parseACMEServer) +} + +// parseACMEServer sets up an ACME server handler from Caddyfile tokens. +// +// acme_server [<matcher>] +// +func parseACMEServer(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) { + var as Handler + for h.Next() { + if h.NextArg() { + return nil, h.ArgErr() + } + } + return as, nil +} |