Changes with Apache 2.0.31-dev
+ *) Add a timeout option to the proxy code 'ProxyTimeout'
+ [Ian Holsman]
*) FTP directory listings are now always retrieved in ASCII mode.
The FTP proxy properly escapes URI's and HTML in the generated
<li><a href="#proxyreceivebuffersize">ProxyReceiveBufferSize</a>
<li><a href="#proxyremote">ProxyRemote</a>
<li><a href="#proxyrequests">ProxyRequests</a>
+<li><a href="#proxytimeout">ProxyTimeout</a>
<li><a href="#proxyvia">ProxyVia</a>
</ul>
<hr>
+<h2><a name="proxytimeout">ProxyTimeout</a> directive</h2>
+<a
+ href="directive-dict.html#Syntax"
+ REL="Help"
+><strong>Syntax:</strong></a> ProxyTimeout <em>n</em> seconds<br>
+<a
+ href="directive-dict.html#Default"
+ REL="Help"
+><strong>Default:</strong></a> <em>server default timeout</em><br>
+<a
+ href="directive-dict.html#Context"
+ REL="Help"
+><strong>Context:</strong></a> server config, virtual host<br>
+<a
+ href="directive-dict.html#Override"
+ REL="Help"
+><strong>Override:</strong></a> <em>Not applicable</em><br>
+<a
+ href="directive-dict.html#Status"
+ REL="Help"
+><strong>Status:</strong></a> Base<br>
+<a
+ href="directive-dict.html#Module"
+ REL="Help"
+><strong>Module:</strong></a> mod_proxy<br>
+<a
+ href="directive-dict.html#Compatibility"
+ REL="Help"
+><strong>Compatibility:</strong></a> ProxyDomain is only available in
+Apache 2.0.31 and later.<p>
+
+<p>This directive allows a user to specifiy a timeout on proxy requests.
+This is usefull when you have a slow/buggy appserver which hangs,
+and you would rather just return a timeout and fail gracefully instead
+of waiting however long it takes the server to return
+</p>
+<hr>
+
+
<h2><a name="proxydomain">ProxyDomain</a> directive</h2>
<a
href="directive-dict.html#Syntax"
ps->error_override_set = 0;
ps->preserve_host_set =0;
ps->preserve_host =0;
+ ps->timeout=0;
+ ps->timeout_set=0;
return ps;
}
ps->maxfwd = (overrides->maxfwd_set == 0) ? base->maxfwd : overrides->maxfwd;
ps->error_override = (overrides->error_override_set == 0) ? base->error_override : overrides->error_override;
ps->preserve_host = (overrides->preserve_host_set == 0) ? base->preserve_host : overrides->preserve_host;
+ ps->timeout= (overrides->timeout_set == 0) ? base->timeout : overrides->timeout;
return ps;
}
psf->maxfwd_set = 1;
return NULL;
}
+static const char*
+ set_proxy_timeout(cmd_parms *parms, void *dummy, const char *arg)
+{
+ proxy_server_conf *psf =
+ ap_get_module_config(parms->server->module_config, &proxy_module);
+ int timeout;
+
+ timeout=atoi(arg);
+ if (timeout<1) {
+ return "Proxy Timeout must be at least 1 second.";
+ }
+ psf->timeout_set=1;
+ psf->timeout=timeout;
+
+ return NULL;
+}
static const char*
set_via_opt(cmd_parms *parms, void *dummy, const char *arg)
"use our error handling pages instead of the servers' we are proxying"),
AP_INIT_FLAG("ProxyPreserveHost", set_preserve_host, NULL, RSRC_CONF,
"on if we should preserve host header while proxying"),
+ AP_INIT_TAKE1("ProxyTimeout", set_proxy_timeout, NULL, RSRC_CONF,
+ "Set the timeout (in seconds) for a proxied connection. "
+ "This overrides the server timeout"),
{NULL}
};
int error_override_set;
int preserve_host;
int preserve_host_set;
+ int timeout;
+ int timeout_set;
} proxy_server_conf;
}
/* Set a timeout on the socket */
- apr_setsocketopt(sock, APR_SO_TIMEOUT, (int)(r->server->timeout * APR_USEC_PER_SEC));
+ if (conf->timeout_set == 1 ) {
+ apr_setsocketopt(sock,
+ APR_SO_TIMEOUT,
+ (int)(conf->timeout * APR_USEC_PER_SEC));
+ }
+ else {
+ apr_setsocketopt(sock,
+ APR_SO_TIMEOUT,
+ (int)(r->server->timeout * APR_USEC_PER_SEC));
+ }
/* make the connection out of the socket */
rv = apr_connect(sock, connect_addr);
}
/* Set a timeout on the socket */
- apr_setsocketopt(sock, APR_SO_TIMEOUT, (int)(r->server->timeout * APR_USEC_PER_SEC));
+ if (conf->timeout_set == 1) {
+ apr_setsocketopt(sock,
+ APR_SO_TIMEOUT,
+ (int)(conf->timeout * APR_USEC_PER_SEC));
+ }
+ else {
+ apr_setsocketopt(sock,
+ APR_SO_TIMEOUT,
+ (int)(r->server->timeout * APR_USEC_PER_SEC));
+ }
ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server,
"proxy: FTP: socket has been created");
#endif
/* Set a timeout on the socket */
- apr_setsocketopt(p_conn->sock, APR_SO_TIMEOUT,
+ if (conf->timeout_set == 1) {
+ apr_setsocketopt(p_conn->sock, APR_SO_TIMEOUT,
+ (int)(conf->timeout * APR_USEC_PER_SEC));
+ }
+ else {
+ apr_setsocketopt(p_conn->sock, APR_SO_TIMEOUT,
(int)(r->server->timeout * APR_USEC_PER_SEC));
+ }
ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
"proxy: socket has been created");