You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: gateway/src/apicast/policy/request_unbuffered/README.md
+12-14Lines changed: 12 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,15 +5,13 @@
5
5
When enable this policy will dymanically sets the [`proxy_request_buffering: off`](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_request_buffering
6
6
) directive per service.
7
7
8
-
9
8
## Technical details
10
9
11
-
By default, NGINX reads the entire request body into memory (or buffers large requests into disk) before proxying it to the upstream server. However, reading bodies can become expensive, especially when requests with large payloads are sent.
10
+
By default, NGINX reads the entire request body into memory or buffers large requests to disk before forwarding them to the upstream server. Reading bodies can become expensive, especially when sending requests containing large payloads.
12
11
13
-
For example, when the client sends 10GB, NGINX will buffer the entire 10GB to disk before sending anything to
14
-
the upstream server.
12
+
For example, when the client sends 10GB, NGINX will buffer the entire 10GB to disk before sending anything to the upstream server.
15
13
16
-
When `proxy_request_buffering` is in the chain, request buffering will be disabled and the request body will be sent to the proxied server immediately as it received. This can help minimize time spent sending data to a service and disk I/O for requests with big body. However, there are caveats and corner cases applied, [**Caveats**](#caveats)
14
+
When the `request_unbuffered` is in the chain, request buffering is disabled, sending the request body to the proxied server immediately upon receiving it. This can help minimize time spent sending data to a service and disk I/O for requests with big body. However, there are caveats and corner cases applied, [**Caveats**](#caveats)
17
15
18
16
The policy also provides a consistent behavior across multiple scenarios like:
19
17
@@ -30,10 +28,15 @@ The policy also provides a consistent behavior across multiple scenarios like:
30
28
31
29
## Why don't we also support disable response buffering?
32
30
33
-
The response buffering is enabled by default in NGINX (the [`proxy_buffering: on`]() directive). It does
34
-
this to shield the backend against slow clients ([slowloris attack](https://en.wikipedia.org/wiki/Slowloris_(computer_security))).
31
+
The response buffering is enabled by default in NGINX (the [`proxy_buffering: on`]() directive). It does this to shield the backend against slow clients ([slowloris attack](https://en.wikipedia.org/wiki/Slowloris_(computer_security))).
32
+
33
+
If the `proxy_buffering` is disabled, the upstream server keeps the connection open until all data is received by the client. NGINX [advises](https://www.nginx.com/blog/avoiding-top-10-nginx-configuration-mistakes/#proxy_buffering-off) against disabling `proxy_buffering` as it will potentially waste upstream server resources.
34
+
35
+
## Why does upstream receive a "Content-Length" header when the original request is sent with "Transfer-Encoding: chunked"
36
+
37
+
For a request with "small" body that fits into [`client_body_buffer_size`](https://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_buffer_size) and with header "Transfer-Encoding: chunked", NGINX will always read and know the length of the body. Then it will send the request to upstream with the "Content-Length" header.
35
38
36
-
If the `proxy_buffering` is disabled, the upstream server will be forced to keep the connection open until all data has been received by the client. Thereforce, NGINX [advises](https://www.nginx.com/blog/avoiding-top-10-nginx-configuration-mistakes/#proxy_buffering-off) against disabling `proxy_buffering` as it will potentially waste upstream server resources.
39
+
If a client uses chunked transfer encoding with HTTP/1.0, NGINX will always buffer the request body
37
40
38
41
## Example configuration
39
42
@@ -89,11 +92,6 @@ Use with Camel Proxy policy
89
92
90
93
## Caveats
91
94
92
-
- Because APIcast allows defining mapping rules based on request content, ie `POST /some_path?a_param={a_value}`
93
-
will match a request like `POST "http://apicast_host:8080/some_path"` with a form URL-encoded body like: `a_param=abc`
94
-
, requests with `Content-type: application/x-www-form-urlencoded` will always be buffered regardless of the
95
+
- APIcast allows defining of mapping rules based on request content. For example, `POST /some_path?a_param={a_value}` will match a request like `POST "http://apicast_host:8080/some_path"` with a form URL-encoded body like: `a_param=abc`, requests with `Content-type: application/x-www-form-urlencoded` will always be buffered regardless of the
95
96
`request_unbuffered` policy is enabled or not.
96
-
- For a request with "small" body that fits into [`client_body_buffer_size`](https://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_buffer_size) and with header "Transfer-Encoding: chunked", NGINX will always read and know the length of the body.
97
-
Then it will send the request to upstream with the "Content-Length" header.
98
-
- If a client uses chunked transfer encoding with HTTP/1.0, NGINX will always buffer the request body
99
97
- Disable request buffering could potentially expose the backend to [slowloris attack](https://en.wikipedia.org/wiki/Slowloris_(computer_security)). Therefore, we recommend to only use this policy when needed.
0 commit comments