<ol>
<li>
- Allow 10 seconds to receive the request including the headers and
- 30 seconds for receiving the request body:
+ Allow for 5 seconds to complete the TLS handshake, 10 seconds to
+ receive the request headers and 30 seconds for receiving the
+ request body:
<highlight language="config">
- RequestReadTimeout header=10 body=30
+ RequestReadTimeout handshake=5 header=10 body=30
</highlight>
</li>
</li>
<li>
- Allow at least 10 seconds to receive the request including the headers.
+ Allow at least 10 seconds to receive the request headers.
If the client sends data, increase the timeout by 1 second for every
500 bytes received. But do not allow more than 30 seconds for the
- request including the headers:
+ request headers:
<highlight language="config">
RequestReadTimeout header=10-30,MinRate=500
<directivesynopsis>
<name>RequestReadTimeout</name>
-<description>Set timeout values for receiving request headers and body from client.
+<description>Set timeout values for completing the TLS handshake, receiving
+the request headers and/or body from client.
</description>
<syntax>RequestReadTimeout
+[handshake=<var>timeout</var>[-<var>maxtimeout</var>][,MinRate=<var>rate</var>]
[header=<var>timeout</var>[-<var>maxtimeout</var>][,MinRate=<var>rate</var>]
[body=<var>timeout</var>[-<var>maxtimeout</var>][,MinRate=<var>rate</var>]
</syntax>
-<default>RequestReadTimeout header=20-40,MinRate=500 body=20,MinRate=500</default>
+<default>RequestReadTimeout handshake=0 header=20-40,MinRate=500 body=20,MinRate=500</default>
<contextlist><context>server config</context><context>virtual host</context>
</contextlist>
-<compatibility>Defaulted to disabled in
-version 2.3.14 and earlier.</compatibility>
+<compatibility>Defaulted to disabled in version 2.3.14 and earlier. The
+<code>handshake</code> stage is available since version 2.5.
+</compatibility>
<usage>
- <p>This directive can set various timeouts for receiving the request headers
- and the request body from the client. If the client fails to send headers or
- body within the configured time, a <code>408 REQUEST TIME OUT</code> error
- is sent.</p>
+ <p>This directive can set various timeouts for completing the TLS handshake,
+ receiving the request headers and/or the request body from the client.
+ If the client fails to complete each of these stages within the configured
+ time, a <code>408 REQUEST TIME OUT</code> error is sent.</p>
- <p>For SSL virtual hosts, the header timeout values include the time needed
- to do the initial SSL handshake. If the user's browser is configured to
+ <p>For SSL virtual hosts, the <code>handshake</code> timeout values is the time
+ needed to do the initial SSL handshake. If the user's browser is configured to
query certificate revocation lists and the CRL server is not reachable, the
initial SSL handshake may take a significant time until the browser gives up
- waiting for the CRL. Therefore the header timeout values should not be set
- to very low values for SSL virtual hosts.
+ waiting for the CRL. Therefore the <code>handshake</code> timeout should take
+ this possible overhead into consideration for SSL virtual hosts (if necessary).
The body timeout values include the time needed for SSL renegotiation
(if necessary).</p>
<p>When an <directive module="core">AcceptFilter</directive> is in use
(usually the case on Linux and FreeBSD), the socket is not sent to the
server process before at least one byte (or the whole request for
- <code>httpready</code>) is received. The header timeout configured with
- <directive>RequestReadTimeout</directive> is only effective after the server process has
- received the socket.</p>
+ <code>httpready</code>) is received. The handshake and header timeouts
+ configured with <directive>RequestReadTimeout</directive> are only effective
+ after the server process has received the socket.</p>
- <p>For each of the two timeout types (header or body), there are three ways
- to specify the timeout:
+ <p>For each of the three timeout stages (handshake, header or body), there are
+ three ways to specify the timeout:
</p>
<ul>
<li><strong>Fixed timeout value</strong>:<br />
- <example><var>type</var>=<var>timeout</var></example>
+ <example><var>stage</var>=<var>timeout</var></example>
- <p>The time in seconds allowed for reading all of the request headers or
- body, respectively. A value of 0 means no limit.</p>
+ <p>The time in seconds allowed for completing the whole stage (handshaking,
+ reading all of the request headers or body). A value of 0 means no limit.</p>
</li>
<li><strong>Disable module for a vhost</strong>:<br />
- <example>header=0 body=0</example>
+ <example>handshake=0 header=0 body=0</example>
- <p>This disables <module>mod_reqtimeout</module> completely.</p>
+ <p>This disables <module>mod_reqtimeout</module> completely (note that
+ <code>handshake=0</code> is the default already and could be omitted).</p>
</li>
<li><strong>Timeout value that is increased when data is
received</strong>:<br />
<example>
- <var>type</var>=<var>timeout</var>,MinRate=<var>data_rate</var>
+ <var>stage</var>=<var>timeout</var>,MinRate=<var>data_rate</var>
</example>
<p>Same as above, but whenever data is received, the timeout value is
<li><strong>Timeout value that is increased when data is received, with an
upper bound</strong>:<br />
<example>
- <var>type</var>=<var>timeout</var>-<var>maxtimeout</var>,MinRate=<var>data_rate</var>
+ <var>stage</var>=<var>timeout</var>-<var>maxtimeout</var>,MinRate=<var>data_rate</var>
</example>
<p>Same as above, but the timeout will not be increased above the second
module AP_MODULE_DECLARE_DATA reqtimeout_module;
#define UNSET -1
+#define MRT_DEFAULT_handshake_TIMEOUT 0 /* disabled */
+#define MRT_DEFAULT_handshake_MAX_TIMEOUT 0
+#define MRT_DEFAULT_handshake_MIN_RATE APR_INT32_MAX
#define MRT_DEFAULT_header_TIMEOUT 20
#define MRT_DEFAULT_header_MAX_TIMEOUT 40
#define MRT_DEFAULT_header_MIN_RATE 500
typedef struct
{
+ reqtimeout_stage_t handshake; /* Handshaking (TLS) */
reqtimeout_stage_t header; /* Reading the HTTP header */
reqtimeout_stage_t body; /* Reading the HTTP body */
} reqtimeout_srv_cfg;
} reqtimeout_con_cfg;
static const char *const reqtimeout_filter_name = "reqtimeout";
+static int default_handshake_rate_factor;
static int default_header_rate_factor;
static int default_body_rate_factor;
&reqtimeout_module);
AP_DEBUG_ASSERT(cfg != NULL);
- if (cfg->header.timeout == 0 && cfg->body.timeout == 0) {
+ /* For compatibility, handshake timeout is disabled when UNSET (< 0) */
+ if (cfg->handshake.timeout <= 0
+ && cfg->header.timeout == 0
+ && cfg->body.timeout == 0) {
/* disabled for this vhost */
return DECLINED;
}
ap_set_module_config(c->conn_config, &reqtimeout_module, ccfg);
ap_add_output_filter(reqtimeout_filter_name, ccfg, NULL, c);
ap_add_input_filter(reqtimeout_filter_name, ccfg, NULL, c);
+
+ if (cfg->handshake.timeout > 0) {
+ INIT_STAGE(cfg, ccfg, handshake);
+ }
}
/* we are not handling the connection, we just do initialization */
{
reqtimeout_srv_cfg *cfg = apr_pcalloc(p, sizeof(reqtimeout_srv_cfg));
+ UNSET_STAGE(cfg, handshake);
UNSET_STAGE(cfg, header);
UNSET_STAGE(cfg, body);
reqtimeout_srv_cfg *add = add_;
reqtimeout_srv_cfg *cfg = apr_pcalloc(p, sizeof(reqtimeout_srv_cfg));
+ MERGE_STAGE(cfg, base, add, handshake);
MERGE_STAGE(cfg, base, add, header);
MERGE_STAGE(cfg, base, add, body);
char *rate_str = NULL, *initial_str, *max_str = NULL;
reqtimeout_stage_t *stage;
- if (!strcasecmp(key, "header")) {
+ if (!strcasecmp(key, "handshake")) {
+ stage = &conf->handshake;
+ }
+ else if (!strcasecmp(key, "header")) {
stage = &conf->header;
}
else if (!strcasecmp(key, "body")) {
* e.g. mod_ftp. Also, if mod_reqtimeout used the pre_connection hook, it
* would be inserted on mod_proxy's backend connections.
*/
- ap_hook_process_connection(reqtimeout_init, NULL, NULL, APR_HOOK_LAST);
+ ap_hook_process_connection(reqtimeout_init, NULL, NULL, APR_HOOK_FIRST);
ap_hook_pre_read_request(reqtimeout_before_header, NULL, NULL,
APR_HOOK_MIDDLE);
ap_hook_post_read_request(reqtimeout_before_body, NULL, NULL,
APR_HOOK_MIDDLE);
+#if MRT_DEFAULT_HANDSHAKE_MIN_RATE > 0
+ default_handshake_rate_factor = apr_time_from_sec(1) /
+ MRT_DEFAULT_HANDSHAKE_MIN_RATE;
+#endif
#if MRT_DEFAULT_HEADER_MIN_RATE > 0
default_header_rate_factor = apr_time_from_sec(1) /
MRT_DEFAULT_HEADER_MIN_RATE;
static const command_rec reqtimeout_cmds[] = {
AP_INIT_RAW_ARGS("RequestReadTimeout", set_reqtimeouts, NULL, RSRC_CONF,
- "Set various timeout parameters for reading request "
- "headers and body"),
+ "Set various timeout parameters for TLS handshake and/or "
+ "reading request headers and body"),
{NULL}
};