@marcel91200 / caddy Mirror · read-only / commits / 0bdb8aa8
Fork 0

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

acmeserver: Don't set host for directory links by default

This makes the server more easily proxied.

Matthew Holt committed Jul 1, 2021 at 17:20 UTC 0bdb8aa82d7cef64dae3f75f19c680922237e658
1 file changed +6 -13
modules/caddypki/acmeserver/acmeserver.go
+6 -13
@@ -50,17 +50,16 @@ type Handler struct {
50
51 // The hostname or IP address by which ACME clients
52 // will access the server. This is used to populate
53 - // the ACME directory endpoint. Default: localhost.
53 + // the ACME directory endpoint. If not set, the Host
54 + // header of the request will be used.
55 // COMPATIBILITY NOTE / TODO: This property may go away in the
55 - // future, as it is currently only required due to
56 - // limitations in the underlying library. Do not rely
57 - // on this property long-term; check release notes.
56 + // future. Do not rely on this property long-term; check release notes.
57 Host string `json:"host,omitempty"`
58
59 // The path prefix under which to serve all ACME
60 // endpoints. All other requests will not be served
61 // by this handler and will be passed through to
63 - // the next one. Default: "/acme/"
62 + // the next one. Default: "/acme/".
63 // COMPATIBILITY NOTE / TODO: This property may go away in the
64 // future, as it is currently only required due to
65 // limitations in the underlying library. Do not rely
@@ -93,9 +92,6 @@ func (ash *Handler) Provision(ctx caddy.Context) error {
92 if ash.CA == "" {
93 ash.CA = caddypki.DefaultCAID
94 }
96 - if ash.Host == "" {
97 - ash.Host = defaultHost
98 - }
95 if ash.PathPrefix == "" {
96 ash.PathPrefix = defaultPathPrefix
97 }
@@ -151,7 +147,7 @@ func (ash *Handler) Provision(ctx caddy.Context) error {
147 acmeRouterHandler := acmeAPI.NewHandler(acmeAPI.HandlerOptions{
148 CA: auth,
149 DB: acmeDB, // stores all the server state
154 - DNS: ash.Host, // used for directory links; TODO: not needed (follow-up upstream with step-ca)
150 + DNS: ash.Host, // used for directory links
151 Prefix: strings.Trim(ash.PathPrefix, "/"), // used for directory links
152 })
153
@@ -219,10 +215,7 @@ func (ash Handler) openDatabase() (*db.AuthDB, error) {
215 return database.(databaseCloser).DB, err
216 }
217
222 -const (
223 - defaultHost = "localhost"
224 - defaultPathPrefix = "/acme/"
225 -)
218 +const defaultPathPrefix = "/acme/"
219
220 var keyCleaner = regexp.MustCompile(`[^\w.-_]`)
221 var databasePool = caddy.NewUsagePool()