@marcel91200 / caddy Mirror · read-only / commits / ac83b7e2
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 13, 06:45 UTC

admin: Add `CADDY_ADMIN` env var to override the default (#5332)

Francis Lavoie committed Feb 6, 2023 at 12:55 UTC ac83b7e218e3c3eb4ef26922196759434b130786
1 file changed +14 -1
admin.go
+14 -1
@@ -46,6 +46,17 @@ import (
46 "go.uber.org/zap/zapcore"
47 )
48
49 +func init() {
50 + // The hard-coded default `DefaultAdminListen` can be overidden
51 + // by setting the `CADDY_ADMIN` environment variable.
52 + // The environment variable may be used by packagers to change
53 + // the default admin address to something more appropriate for
54 + // that platform. See #5317 for discussion.
55 + if env, exists := os.LookupEnv("CADDY_ADMIN"); exists {
56 + DefaultAdminListen = env
57 + }
58 +}
59 +
60 // AdminConfig configures Caddy's API endpoint, which is used
61 // to manage Caddy while it is running.
62 type AdminConfig struct {
@@ -57,7 +68,9 @@ type AdminConfig struct {
68
69 // The address to which the admin endpoint's listener should
70 // bind itself. Can be any single network address that can be
60 - // parsed by Caddy. Accepts placeholders. Default: localhost:2019
71 + // parsed by Caddy. Accepts placeholders.
72 + // Default: the value of the `CADDY_ADMIN` environment variable,
73 + // or `localhost:2019` otherwise.
74 Listen string `json:"listen,omitempty"`
75
76 // If true, CORS headers will be emitted, and requests to the