diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b18b3cbf7..22e700bad8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ This release adds an embedded SQLite database for storing metadata required by t 1. [21888](https://github.com/influxdata/influxdb/pull/21888/): Ported the `influxd inspect dump-wal` command from 1.x. 1. [21828](https://github.com/influxdata/influxdb/pull/21828): Added the command `influx inspect verify-wal`. 1. [21814](https://github.com/influxdata/influxdb/pull/21814): Ported the `influxd inspect report-tsm` command from 1.x. +1. [21910](https://github.com/influxdata/influxdb/pull/21910): Added `--ui-disabled` option to `influxd` to allow for running with the UI disabled. ### Bug Fixes diff --git a/cmd/influxd/launcher/cmd.go b/cmd/influxd/launcher/cmd.go index b9de8c4dd8..b5b0987123 100644 --- a/cmd/influxd/launcher/cmd.go +++ b/cmd/influxd/launcher/cmd.go @@ -149,6 +149,7 @@ type InfluxdOpts struct { ProfilingDisabled bool MetricsDisabled bool + UIDisabled bool NatsPort int NatsMaxPayloadBytes int @@ -199,6 +200,7 @@ func NewOpts(viper *viper.Viper) *InfluxdOpts { ProfilingDisabled: false, MetricsDisabled: false, + UIDisabled: false, StoreType: DiskStore, SecretStore: BoltStore, @@ -580,5 +582,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 d017e69101..0a6af4679a 100644 --- a/cmd/influxd/launcher/launcher.go +++ b/cmd/influxd/launcher/launcher.go @@ -759,6 +759,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 0d64f0bee4..177f066abd 100644 --- a/http/api_handler.go +++ b/http/api_handler.go @@ -34,6 +34,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 errors.HTTPErrorHandler SessionRenewDisabled bool diff --git a/http/platform_handler.go b/http/platform_handler.go index 24ba86b3ea..857383f706 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)