diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ab842dba6f..3bb330c4514 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ This release upgrades the project to `go` version 1.16. Because of the version bump to `go`, the macOS build for this release requires at least version 10.12 Sierra to run. +### Features + +1. [21922](https://github.com/influxdata/influxdb/pull/21922): Add `--ui-disabled` option to `influxd` to allow for running with the UI disabled. + ### Bug Fixes 1. [21748](https://github.com/influxdata/influxdb/pull/21748): Rename arm rpms with yum-compatible names. diff --git a/cmd/influxd/launcher/cmd.go b/cmd/influxd/launcher/cmd.go index fac62ed3e62..64482e6c7b8 100644 --- a/cmd/influxd/launcher/cmd.go +++ b/cmd/influxd/launcher/cmd.go @@ -147,6 +147,7 @@ type InfluxdOpts struct { ProfilingDisabled bool MetricsDisabled bool + UIDisabled bool NatsPort int NatsMaxPayloadBytes int @@ -196,6 +197,7 @@ func NewOpts(viper *viper.Viper) *InfluxdOpts { ProfilingDisabled: false, MetricsDisabled: false, + UIDisabled: false, StoreType: BoltStore, SecretStore: BoltStore, @@ -561,5 +563,12 @@ func (o *InfluxdOpts) BindCliOpts() []cli.Opt { Desc: "Don't expose metrics over HTTP at /metrics", Default: o.MetricsDisabled, }, + // UI Config + { + DestP: &o.UIDisabled, + Flag: "ui-disabled", + Default: o.UIDisabled, + Desc: "Disable the InfluxDB UI", + }, } } diff --git a/cmd/influxd/launcher/launcher.go b/cmd/influxd/launcher/launcher.go index b9c4abe6844..72f85b4431c 100644 --- a/cmd/influxd/launcher/launcher.go +++ b/cmd/influxd/launcher/launcher.go @@ -704,6 +704,7 @@ func (m *Launcher) run(ctx context.Context, opts *InfluxdOpts) (err error) { m.apibackend = &http.APIBackend{ AssetsPath: opts.AssetsPath, + UIDisabled: opts.UIDisabled, HTTPErrorHandler: kithttp.ErrorHandler(0), Logger: m.log, SessionRenewDisabled: opts.SessionRenewDisabled, diff --git a/http/api_handler.go b/http/api_handler.go index 6e77e765486..3ec888ebe31 100644 --- a/http/api_handler.go +++ b/http/api_handler.go @@ -30,6 +30,7 @@ type APIHandler struct { // an APIHandler. type APIBackend struct { AssetsPath string // if empty then assets are served from bindata. + UIDisabled bool // if true requests for the UI will return 404 Logger *zap.Logger influxdb.HTTPErrorHandler SessionRenewDisabled bool diff --git a/http/platform_handler.go b/http/platform_handler.go index 857428b2686..f3d749658b9 100644 --- a/http/platform_handler.go +++ b/http/platform_handler.go @@ -35,6 +35,10 @@ func NewPlatformHandler(b *APIBackend, opts ...APIHandlerOptFn) *PlatformHandler h.RegisterNoAuthRoute("GET", "/api/v2/swagger.json") assetHandler := static.NewAssetHandler(b.AssetsPath) + if b.UIDisabled { + b.Logger.Debug("http server running with UI disabled") + assetHandler = http.NotFoundHandler() + } wrappedHandler := kithttp.SetCORS(h) wrappedHandler = kithttp.SkipOptions(wrappedHandler)