Skip to content

Commit

Permalink
api: when configured securely, bind to all available interfaces by de…
Browse files Browse the repository at this point in the history
…fault
  • Loading branch information
yaauie committed Oct 14, 2021
1 parent 77c3053 commit 909e65b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/static/settings-file.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ Values other than `disabled` are currently considered BETA, and may produce unin
| `api.http.host`
| The bind address for the HTTP API endpoint.
By default, the {ls} HTTP API binds only to the local loopback interface.
When configured securely (`api.ssl.enabled: true` and `api.auth.type: basic`), the HTTP API binds to _all_ available interfaces.
| `"127.0.0.1"`

| `api.http.port`
Expand Down
9 changes: 8 additions & 1 deletion logstash-core/lib/logstash/webserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class WebServer

def self.from_settings(logger, agent, settings)
options = {}
options[:http_host] = settings.get('api.http.host')
options[:http_host] = settings.get('api.http.host') # may be overridden later if API configured securely
options[:http_port] = settings.get('api.http.port')
options[:http_environment] = settings.get('api.environment')

Expand All @@ -52,6 +52,13 @@ def self.from_settings(logger, agent, settings)
options[:auth_basic] = auth_basic.freeze
end

if !settings.set?('api.http.host')
if settings.get('api.ssl.enabled') && settings.get('api.auth.type') == 'basic'
logger.info("API configured securely with SSL and Basic Auth. Defaulting `api.http.host` to all available interfaces")
options[:http_host] = '0.0.0.0'
end
end

new(logger, agent, options)
end

Expand Down

0 comments on commit 909e65b

Please sign in to comment.