Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
caddypki: Add 'acme_server' Caddyfile directive
Matthew Holt committed
Jun 3, 2020 at 09:59 UTC
a285fe41296cf786b21f637ebe9e5f265eddaa8a
3 files changed
+48
-2
caddyconfig/httpcaddyfile/directives.go
+2
-1
@@ -56,14 +56,15 @@ var directiveOrder = []string{
56
57
// special routing directives
58
"handle",
59
- "route",
59
"handle_path",
60
+ "route",
61
62
// handlers that typically respond to requests
63
"respond",
64
"reverse_proxy",
65
"php_fastcgi",
66
"file_server",
67
+ "acme_server",
68
}
69
70
// directiveIsOrdered returns true if dir is
modules/caddypki/acmeserver/acmeserver.go
+8
-1
@@ -48,13 +48,20 @@ type Handler struct {
48
// The hostname or IP address by which ACME clients
49
// will access the server. This is used to populate
50
// the ACME directory endpoint. Default: localhost.
51
- // TODO: this is probably not needed - check with smallstep
51
+ // COMPATIBILITY NOTE / TODO: This property may go away in the
52
+ // future, as it is currently only required due to
53
+ // limitations in the underlying library. Do not rely
54
+ // on this property long-term; check release notes.
55
Host string `json:"host,omitempty"`
56
57
// The path prefix under which to serve all ACME
58
// endpoints. All other requests will not be served
59
// by this handler and will be passed through to
60
// the next one. Default: "/acme/"
61
+ // COMPATIBILITY NOTE / TODO: This property may go away in the
62
+ // future, as it is currently only required due to
63
+ // limitations in the underlying library. Do not rely
64
+ // on this property long-term; check release notes.
65
PathPrefix string `json:"path_prefix,omitempty"`
66
67
acmeEndpoints http.Handler
modules/caddypki/acmeserver/caddyfile.go
new
+38
@@ -0,0 +1,38 @@
1
+// Copyright 2015 Matthew Holt and The Caddy Authors
2
+//
3
+// Licensed under the Apache License, Version 2.0 (the "License");
4
+// you may not use this file except in compliance with the License.
5
+// You may obtain a copy of the License at
6
+//
7
+// http://www.apache.org/licenses/LICENSE-2.0
8
+//
9
+// Unless required by applicable law or agreed to in writing, software
10
+// distributed under the License is distributed on an "AS IS" BASIS,
11
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+// See the License for the specific language governing permissions and
13
+// limitations under the License.
14
+
15
+package acmeserver
16
+
17
+import (
18
+ "github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile"
19
+ "github.com/caddyserver/caddy/v2/modules/caddyhttp"
20
+)
21
+
22
+func init() {
23
+ httpcaddyfile.RegisterHandlerDirective("acme_server", parseACMEServer)
24
+}
25
+
26
+// parseACMEServer sets up an ACME server handler from Caddyfile tokens.
27
+//
28
+// acme_server [<matcher>]
29
+//
30
+func parseACMEServer(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) {
31
+ var as Handler
32
+ for h.Next() {
33
+ if h.NextArg() {
34
+ return nil, h.ArgErr()
35
+ }
36
+ }
37
+ return as, nil
38
+}