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 70241f7 commit 42c8826
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
10 changes: 5 additions & 5 deletions config/logstash.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@
#
# api.enabled: true
#
# By default, the HTTP API is bound to only the host's local loopback interface,
# ensuring that it is not accessible to the rest of the network. Because the API
# includes neither authentication nor authorization and has not been hardened or
# tested for use as a publicly-reachable API, binding to publicly accessible IPs
# should be avoided where possible.
# By default, the HTTP API is not secured and is therefore bound to only the
# host's loopback interface, ensuring that it is not accessible to the rest of
# the network.
# When secured with SSL and Basic Auth, the API is bound to _all_ interfaces
# unless configured otherwise.
#
# api.http.host: 127.0.0.1
#
Expand Down
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 42c8826

Please sign in to comment.