http.asciidoc 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. [[modules-http]]
  2. === HTTP
  3. [[modules-http-description]]
  4. // tag::modules-http-description-tag[]
  5. The HTTP layer exposes {es}'s REST APIs over HTTP. Clients send HTTP requests
  6. to a node in the cluster which either handles it locally or else passes it on
  7. to other nodes for further processing using the <<modules-transport,Transport
  8. layer>>.
  9. When possible, consider using {wikipedia}/Keepalive#HTTP_Keepalive[HTTP keep
  10. alive] when connecting for better performance and try to get your favorite
  11. client not to do {wikipedia}/Chunked_transfer_encoding[HTTP chunking].
  12. // end::modules-http-description-tag[]
  13. [http-settings]
  14. ==== HTTP settings
  15. The following settings can be configured for HTTP. These settings also use the common <<modules-network,network settings>>.
  16. NOTE: HTTP settings cannot be updated dynamically. You must configure these settings in the {es} <<settings, configuration file>>
  17. and restart {es} for changes to take effect.
  18. `http.port`::
  19. A bind port range. Defaults to `9200-9300`.
  20. `http.publish_port`::
  21. The port that HTTP clients should use when
  22. communicating with this node. Useful when a cluster node is behind a
  23. proxy or firewall and the `http.port` is not directly addressable
  24. from the outside. Defaults to the actual port assigned via `http.port`.
  25. `http.bind_host`::
  26. The host address to bind the HTTP service to. Defaults to `http.host` (if set) or `network.bind_host`.
  27. `http.publish_host`::
  28. The host address to publish for HTTP clients to connect to. Defaults to `http.host` (if set) or `network.publish_host`.
  29. `http.host`::
  30. Used to set the `http.bind_host` and the `http.publish_host`.
  31. `http.max_content_length`::
  32. The max content of an HTTP request. Defaults to `100MB`.
  33. `http.max_initial_line_length`::
  34. The max length of an HTTP URL. Defaults to `4KB`.
  35. `http.max_header_size`::
  36. The max size of allowed headers. Defaults to `8KB`.
  37. [[http-compression]]
  38. // tag::http-compression-tag[]
  39. `http.compression` {ess-icon}::
  40. Support for compression when possible (with Accept-Encoding). If HTTPS is enabled, defaults to `false`. Otherwise, defaults to `true`.
  41. +
  42. Disabling compression for HTTPS mitigates potential security risks, such as a
  43. {wikipedia}/BREACH[BREACH attack]. To compress HTTPS traffic,
  44. you must explicitly set `http.compression` to `true`.
  45. // end::http-compression-tag[]
  46. `http.compression_level`::
  47. Defines the compression level to use for HTTP responses. Valid values are in the range of 1 (minimum compression) and 9 (maximum compression). Defaults to `3`.
  48. [[http-cors-enabled]]
  49. // tag::http-cors-enabled-tag[]
  50. `http.cors.enabled` {ess-icon}::
  51. Enable or disable cross-origin resource sharing, which determines whether a browser on another origin can execute requests against {es}. Set to `true` to enable {es} to process pre-flight
  52. {wikipedia}/Cross-origin_resource_sharing[CORS] requests.
  53. {es} will respond to those requests with the `Access-Control-Allow-Origin` header if the `Origin` sent in the request is permitted by the `http.cors.allow-origin` list. Set to `false` (the default) to make {es} ignore the `Origin` request header, effectively disabling CORS requests because {es} will never respond with the `Access-Control-Allow-Origin` response header.
  54. +
  55. NOTE: If the client does not send a pre-flight request with an `Origin` header or it does not check the response headers from the server to validate the
  56. `Access-Control-Allow-Origin` response header, then cross-origin security is
  57. compromised. If CORS is not enabled on {es}, the only way for the client to know is to send a pre-flight request and realize the required response headers are missing.
  58. // end::http-cors-enabled-tag[]
  59. [[http-cors-allow-origin]]
  60. // tag::http-cors-allow-origin-tag[]
  61. `http.cors.allow-origin` {ess-icon}::
  62. Which origins to allow. If you prepend and append a forward slash (`/`) to the value, this will be treated as a regular expression, allowing you to support HTTP and HTTPs. For example, using `/https?:\/\/localhost(:[0-9]+)?/` would return the request header appropriately in both cases. Defaults to no origins allowed.
  63. +
  64. IMPORTANT: A wildcard (`*`) is a valid value but is considered a security risk, as your {es} instance is open to cross origin requests from *anywhere*.
  65. // end::http-cors-allow-origin-tag[]
  66. [[http-cors-max-age]]
  67. // tag::http-cors-max-age-tag[]
  68. `http.cors.max-age` {ess-icon}::
  69. Browsers send a "preflight" OPTIONS-request to determine CORS settings. `max-age` defines how long the result should be cached for. Defaults to `1728000` (20 days).
  70. // end::http-cors-max-age-tag[]
  71. [[http-cors-allow-methods]]
  72. // tag::http-cors-allow-methods-tag[]
  73. `http.cors.allow-methods` {ess-icon}::
  74. Which methods to allow. Defaults to `OPTIONS, HEAD, GET, POST, PUT, DELETE`.
  75. // end::http-cors-allow-methods-tag[]
  76. [[http-cors-allow-headers]]
  77. // tag::http-cors-allow-headers-tag[]
  78. `http.cors.allow-headers` {ess-icon}::
  79. Which headers to allow. Defaults to `X-Requested-With, Content-Type, Content-Length`.
  80. // end::http-cors-allow-headers-tag[]
  81. [[http-cors-allow-credentials]]
  82. // tag::http-cors-allow-credentials-tag[]
  83. `http.cors.allow-credentials` {ess-icon}::
  84. Whether the `Access-Control-Allow-Credentials` header should be returned. Defaults to `false`.
  85. +
  86. NOTE: This header is only returned when the setting is set to `true`.
  87. // end::http-cors-allow-credentials-tag[]
  88. `http.detailed_errors.enabled`::
  89. If `true`, enables the output of detailed error messages and stack traces in the response output. Defaults to `true`.
  90. +
  91. If `false`, use the `error_trace` parameter to <<common-options-error-options,enable stack traces>> and return detailed error messages. Otherwise, only a simple message will be returned.
  92. `http.pipelining.max_events`::
  93. The maximum number of events to be queued up in memory before an HTTP connection is closed, defaults to `10000`.
  94. `http.max_warning_header_count`::
  95. The maximum number of warning headers in client HTTP responses. Defaults to `unbounded`.
  96. `http.max_warning_header_size`::
  97. The maximum total size of warning headers in client HTTP responses. Defaults to `unbounded`.
  98. `http.tcp.no_delay`::
  99. Enable or disable the {wikipedia}/Nagle%27s_algorithm[TCP no delay]
  100. setting. Defaults to `network.tcp.no_delay`.
  101. `http.tcp.keep_alive`::
  102. Configures the `SO_KEEPALIVE` option for this socket, which
  103. determines whether it sends TCP keepalive probes.
  104. Defaults to `network.tcp.keep_alive`.
  105. `http.tcp.keep_idle`:: Configures the `TCP_KEEPIDLE` option for this socket, which
  106. determines the time in seconds that a connection must be idle before
  107. starting to send TCP keepalive probes. Defaults to `network.tcp.keep_idle`, which
  108. uses the system default. This value cannot exceed `300` seconds. Only applicable on
  109. Linux and macOS, and requires Java 11 or newer.
  110. `http.tcp.keep_interval`:: Configures the `TCP_KEEPINTVL` option for this socket,
  111. which determines the time in seconds between sending TCP keepalive probes.
  112. Defaults to `network.tcp.keep_interval`, which uses the system default.
  113. This value cannot exceed `300` seconds. Only applicable on Linux and macOS, and requires
  114. Java 11 or newer.
  115. `http.tcp.keep_count`:: Configures the `TCP_KEEPCNT` option for this socket, which
  116. determines the number of unacknowledged TCP keepalive probes that may be
  117. sent on a connection before it is dropped. Defaults to `network.tcp.keep_count`,
  118. which uses the system default. Only applicable on Linux and macOS, and
  119. requires Java 11 or newer.
  120. `http.tcp.reuse_address`::
  121. Should an address be reused or not. Defaults to `network.tcp.reuse_address`.
  122. `http.tcp.send_buffer_size`::
  123. The size of the TCP send buffer (specified with <<size-units,size units>>).
  124. Defaults to `network.tcp.send_buffer_size`.
  125. `http.tcp.receive_buffer_size`::
  126. The size of the TCP receive buffer (specified with <<size-units,size units>>).
  127. Defaults to `network.tcp.receive_buffer_size`.
  128. [http-rest-request-tracer]
  129. ==== REST request tracer
  130. The HTTP layer has a dedicated tracer logger which, when activated, logs incoming requests. The log can be dynamically activated
  131. by setting the level of the `org.elasticsearch.http.HttpTracer` logger to `TRACE`:
  132. [source,console]
  133. --------------------------------------------------
  134. PUT _cluster/settings
  135. {
  136. "transient" : {
  137. "logger.org.elasticsearch.http.HttpTracer" : "TRACE"
  138. }
  139. }
  140. --------------------------------------------------
  141. You can also control which uris will be traced, using a set of include and exclude wildcard patterns. By default every request will be
  142. traced.
  143. [source,console]
  144. --------------------------------------------------
  145. PUT _cluster/settings
  146. {
  147. "transient" : {
  148. "http.tracer.include" : "*",
  149. "http.tracer.exclude" : ""
  150. }
  151. }
  152. --------------------------------------------------