diff --git a/src/core/server/config/deprecation/core_deprecations.test.ts b/src/core/server/config/deprecation/core_deprecations.test.ts index ca9b8675a2f3a..23cff9d01a416 100644 --- a/src/core/server/config/deprecation/core_deprecations.test.ts +++ b/src/core/server/config/deprecation/core_deprecations.test.ts @@ -120,6 +120,26 @@ describe('core deprecations', () => { }); }); + describe('server.host', () => { + it('logs a warning if server.host is set to "0"', () => { + const { messages } = applyCoreDeprecations({ + server: { host: '0' }, + }); + expect(messages).toMatchInlineSnapshot(` + Array [ + "Support for setting server.host to \\"0\\" in kibana.yml is deprecated and will be removed in Kibana version 8.0.0. Instead use \\"0.0.0.0\\" to bind to all interfaces.", + ] + `); + }); + it('does not log a warning if server.host is not set to "0"', () => { + const { migrated, messages } = applyCoreDeprecations({ + server: { host: '0.0.0.0' }, + }); + expect(migrated.server.host).toEqual('0.0.0.0'); + expect(messages.length).toBe(0); + }); + }); + describe('rewriteBasePath', () => { it('logs a warning is server.basePath is set and server.rewriteBasePath is not', () => { const { messages } = applyCoreDeprecations({ diff --git a/src/core/server/config/deprecation/core_deprecations.ts b/src/core/server/config/deprecation/core_deprecations.ts index 466546d855cea..075b54ad34c03 100644 --- a/src/core/server/config/deprecation/core_deprecations.ts +++ b/src/core/server/config/deprecation/core_deprecations.ts @@ -114,6 +114,16 @@ const mapManifestServiceUrlDeprecation: ConfigDeprecation = (settings, fromPath, return settings; }; +const serverHostZeroDeprecation: ConfigDeprecation = (settings, fromPath, log) => { + if (get(settings, 'server.host') === '0') { + log( + 'Support for setting server.host to "0" in kibana.yml is deprecated and will be removed in Kibana version 8.0.0. ' + + 'Instead use "0.0.0.0" to bind to all interfaces.' + ); + } + return settings; +}; + export const coreDeprecationProvider: ConfigDeprecationProvider = ({ unusedFromRoot, renameFromRoot, @@ -159,4 +169,5 @@ export const coreDeprecationProvider: ConfigDeprecationProvider = ({ rewriteBasePathDeprecation, cspRulesDeprecation, mapManifestServiceUrlDeprecation, + serverHostZeroDeprecation, ];