summaryrefslogtreecommitdiff
path: root/admin.go
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2023-02-06 12:55:16 -0500
committerGitHub <noreply@github.com>2023-02-06 17:55:16 +0000
commitac83b7e218e3c3eb4ef26922196759434b130786 (patch)
treea9b45c3fc44d92fbd42a671aa4ab89298ed29e78 /admin.go
parente62b5fb58619364051551a7ee614fb9949cfe69a (diff)
admin: Add `CADDY_ADMIN` env var to override the default (#5332)
Diffstat (limited to 'admin.go')
-rw-r--r--admin.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/admin.go b/admin.go
index d23c7db..674d06a 100644
--- a/admin.go
+++ b/admin.go
@@ -46,6 +46,17 @@ import (
"go.uber.org/zap/zapcore"
)
+func init() {
+ // The hard-coded default `DefaultAdminListen` can be overidden
+ // by setting the `CADDY_ADMIN` environment variable.
+ // The environment variable may be used by packagers to change
+ // the default admin address to something more appropriate for
+ // that platform. See #5317 for discussion.
+ if env, exists := os.LookupEnv("CADDY_ADMIN"); exists {
+ DefaultAdminListen = env
+ }
+}
+
// AdminConfig configures Caddy's API endpoint, which is used
// to manage Caddy while it is running.
type AdminConfig struct {
@@ -57,7 +68,9 @@ type AdminConfig struct {
// The address to which the admin endpoint's listener should
// bind itself. Can be any single network address that can be
- // parsed by Caddy. Accepts placeholders. Default: localhost:2019
+ // parsed by Caddy. Accepts placeholders.
+ // Default: the value of the `CADDY_ADMIN` environment variable,
+ // or `localhost:2019` otherwise.
Listen string `json:"listen,omitempty"`
// If true, CORS headers will be emitted, and requests to the