http.asciidoc 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. `http.port`::
  17. (<<static-cluster-setting,Static>>)
  18. A bind port range. Defaults to `9200-9300`.
  19. `http.publish_port`::
  20. (<<static-cluster-setting,Static>>)
  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. (<<static-cluster-setting,Static>>)
  27. The host address to bind the HTTP service to. Defaults to `http.host` (if set) or `network.bind_host`.
  28. `http.publish_host`::
  29. (<<static-cluster-setting,Static>>)
  30. The host address to publish for HTTP clients to connect to. Defaults to `http.host` (if set) or `network.publish_host`.
  31. `http.host`::
  32. (<<static-cluster-setting,Static>>)
  33. Used to set the `http.bind_host` and the `http.publish_host`.
  34. `http.max_content_length`::
  35. (<<static-cluster-setting,Static>>)
  36. Maximum length of an HTTP request body. Defaults to `100MB`.
  37. `http.max_initial_line_length`::
  38. (<<static-cluster-setting,Static>>)
  39. The max length of an HTTP URL. Defaults to `4KB`.
  40. `http.max_header_size`::
  41. (<<static-cluster-setting,Static>>)
  42. The max size of allowed headers. Defaults to `8KB`.
  43. [[http-compression]]
  44. // tag::http-compression-tag[]
  45. `http.compression` {ess-icon}::
  46. (<<static-cluster-setting,Static>>)
  47. Support for compression when possible (with Accept-Encoding). If HTTPS is enabled, defaults to `false`. Otherwise, defaults to `true`.
  48. +
  49. Disabling compression for HTTPS mitigates potential security risks, such as a
  50. {wikipedia}/BREACH[BREACH attack]. To compress HTTPS traffic,
  51. you must explicitly set `http.compression` to `true`.
  52. // end::http-compression-tag[]
  53. `http.compression_level`::
  54. (<<static-cluster-setting,Static>>)
  55. 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`.
  56. [[http-cors-enabled]]
  57. // tag::http-cors-enabled-tag[]
  58. `http.cors.enabled` {ess-icon}::
  59. (<<static-cluster-setting,Static>>)
  60. 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
  61. {wikipedia}/Cross-origin_resource_sharing[CORS] requests.
  62. {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.
  63. +
  64. 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
  65. `Access-Control-Allow-Origin` response header, then cross-origin security is
  66. 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.
  67. // end::http-cors-enabled-tag[]
  68. [[http-cors-allow-origin]]
  69. // tag::http-cors-allow-origin-tag[]
  70. `http.cors.allow-origin` {ess-icon}::
  71. (<<static-cluster-setting,Static>>)
  72. 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.
  73. +
  74. 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*.
  75. // end::http-cors-allow-origin-tag[]
  76. [[http-cors-max-age]]
  77. // tag::http-cors-max-age-tag[]
  78. `http.cors.max-age` {ess-icon}::
  79. (<<static-cluster-setting,Static>>)
  80. 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).
  81. // end::http-cors-max-age-tag[]
  82. [[http-cors-allow-methods]]
  83. // tag::http-cors-allow-methods-tag[]
  84. `http.cors.allow-methods` {ess-icon}::
  85. (<<static-cluster-setting,Static>>)
  86. Which methods to allow. Defaults to `OPTIONS, HEAD, GET, POST, PUT, DELETE`.
  87. // end::http-cors-allow-methods-tag[]
  88. [[http-cors-allow-headers]]
  89. // tag::http-cors-allow-headers-tag[]
  90. `http.cors.allow-headers` {ess-icon}::
  91. (<<static-cluster-setting,Static>>)
  92. Which headers to allow. Defaults to `X-Requested-With, Content-Type, Content-Length`.
  93. // end::http-cors-allow-headers-tag[]
  94. [[http-cors-allow-credentials]]
  95. // tag::http-cors-allow-credentials-tag[]
  96. `http.cors.allow-credentials` {ess-icon}::
  97. (<<static-cluster-setting,Static>>)
  98. Whether the `Access-Control-Allow-Credentials` header should be returned. Defaults to `false`.
  99. +
  100. NOTE: This header is only returned when the setting is set to `true`.
  101. // end::http-cors-allow-credentials-tag[]
  102. `http.detailed_errors.enabled`::
  103. (<<static-cluster-setting,Static>>)
  104. If `true`, enables the output of detailed error messages and stack traces in the response output. Defaults to `true`.
  105. +
  106. 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.
  107. `http.pipelining.max_events`::
  108. (<<static-cluster-setting,Static>>)
  109. The maximum number of events to be queued up in memory before an HTTP connection is closed, defaults to `10000`.
  110. `http.max_warning_header_count`::
  111. (<<static-cluster-setting,Static>>)
  112. The maximum number of warning headers in client HTTP responses. Defaults to `unbounded`.
  113. `http.max_warning_header_size`::
  114. (<<static-cluster-setting,Static>>)
  115. The maximum total size of warning headers in client HTTP responses. Defaults to `unbounded`.
  116. `http.tcp.no_delay`::
  117. (<<static-cluster-setting,Static>>)
  118. Enable or disable the {wikipedia}/Nagle%27s_algorithm[TCP no delay]
  119. setting. Defaults to `network.tcp.no_delay`.
  120. `http.tcp.keep_alive`::
  121. (<<static-cluster-setting,Static>>)
  122. Configures the `SO_KEEPALIVE` option for this socket, which
  123. determines whether it sends TCP keepalive probes.
  124. Defaults to `network.tcp.keep_alive`.
  125. `http.tcp.keep_idle`::
  126. (<<static-cluster-setting,Static>>) Configures the `TCP_KEEPIDLE` option for this socket, which
  127. determines the time in seconds that a connection must be idle before
  128. starting to send TCP keepalive probes. Defaults to `network.tcp.keep_idle`, which
  129. uses the system default. This value cannot exceed `300` seconds. Only applicable on
  130. Linux and macOS, and requires Java 11 or newer.
  131. `http.tcp.keep_interval`::
  132. (<<static-cluster-setting,Static>>) Configures the `TCP_KEEPINTVL` option for this socket,
  133. which determines the time in seconds between sending TCP keepalive probes.
  134. Defaults to `network.tcp.keep_interval`, which uses the system default.
  135. This value cannot exceed `300` seconds. Only applicable on Linux and macOS, and requires
  136. Java 11 or newer.
  137. `http.tcp.keep_count`::
  138. (<<static-cluster-setting,Static>>) Configures the `TCP_KEEPCNT` option for this socket, which
  139. determines the number of unacknowledged TCP keepalive probes that may be
  140. sent on a connection before it is dropped. Defaults to `network.tcp.keep_count`,
  141. which uses the system default. Only applicable on Linux and macOS, and
  142. requires Java 11 or newer.
  143. `http.tcp.reuse_address`::
  144. (<<static-cluster-setting,Static>>)
  145. Should an address be reused or not. Defaults to `network.tcp.reuse_address`.
  146. `http.tcp.send_buffer_size`::
  147. (<<static-cluster-setting,Static>>)
  148. The size of the TCP send buffer (specified with <<size-units,size units>>).
  149. Defaults to `network.tcp.send_buffer_size`.
  150. `http.tcp.receive_buffer_size`::
  151. (<<static-cluster-setting,Static>>)
  152. The size of the TCP receive buffer (specified with <<size-units,size units>>).
  153. Defaults to `network.tcp.receive_buffer_size`.
  154. [http-rest-request-tracer]
  155. ==== REST request tracer
  156. The HTTP layer has a dedicated tracer logger which, when activated, logs incoming requests. The log can be dynamically activated
  157. by setting the level of the `org.elasticsearch.http.HttpTracer` logger to `TRACE`:
  158. [source,console]
  159. --------------------------------------------------
  160. PUT _cluster/settings
  161. {
  162. "transient" : {
  163. "logger.org.elasticsearch.http.HttpTracer" : "TRACE"
  164. }
  165. }
  166. --------------------------------------------------
  167. You can also control which uris will be traced, using a set of include and exclude wildcard patterns. By default every request will be
  168. traced.
  169. [source,console]
  170. --------------------------------------------------
  171. PUT _cluster/settings
  172. {
  173. "transient" : {
  174. "http.tracer.include" : "*",
  175. "http.tracer.exclude" : ""
  176. }
  177. }
  178. --------------------------------------------------