summaryrefslogtreecommitdiff
path: root/modules/cache/cache_storage.c
diff options
context:
space:
mode:
authorGraham Leggett <minfrin@apache.org>2010-10-03 13:23:39 +0000
committerGraham Leggett <minfrin@apache.org>2010-10-03 13:23:39 +0000
commitd29eacb4785a851f9c3961124027617b557c7c19 (patch)
tree1451f021d06a81150d172499ec66ef6319a0ec15 /modules/cache/cache_storage.c
parentb9ba2169a93359036299fcd0274294e85b937d9a (diff)
downloadhttpd-d29eacb4785a851f9c3961124027617b557c7c19.tar.gz
mod_cache: Allow control over the base URL of reverse proxied requests
using the CacheKeyBaseURL directive, so that the cache key can be calculated from the endpoint URL instead of the server URL. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1003963 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/cache/cache_storage.c')
-rw-r--r--modules/cache/cache_storage.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/modules/cache/cache_storage.c b/modules/cache/cache_storage.c
index 7b07e38533..d96b76c162 100644
--- a/modules/cache/cache_storage.c
+++ b/modules/cache/cache_storage.c
@@ -414,10 +414,15 @@ apr_status_t cache_generate_key_default(request_rec *r, apr_pool_t* p,
* in the reverse proxy case.
*/
if (!r->proxyreq || (r->proxyreq == PROXYREQ_REVERSE)) {
- /* Use _default_ as the hostname if none present, as in mod_vhost */
- hostname = ap_get_server_name(r);
- if (!hostname) {
- hostname = "_default_";
+ if (conf->base_uri && conf->base_uri->hostname) {
+ hostname = conf->base_uri->hostname;
+ }
+ else {
+ /* Use _default_ as the hostname if none present, as in mod_vhost */
+ hostname = ap_get_server_name(r);
+ if (!hostname) {
+ hostname = "_default_";
+ }
}
}
else if(r->parsed_uri.hostname) {
@@ -449,7 +454,12 @@ apr_status_t cache_generate_key_default(request_rec *r, apr_pool_t* p,
scheme = lcs;
}
else {
- scheme = ap_http_scheme(r);
+ if (conf->base_uri && conf->base_uri->scheme) {
+ scheme = conf->base_uri->scheme;
+ }
+ else {
+ scheme = ap_http_scheme(r);
+ }
}
/*
@@ -460,7 +470,7 @@ apr_status_t cache_generate_key_default(request_rec *r, apr_pool_t* p,
* scheme - if available. Otherwise use the port-number of the current
* server.
*/
- if(r->proxyreq && (r->proxyreq != PROXYREQ_REVERSE)) {
+ if (r->proxyreq && (r->proxyreq != PROXYREQ_REVERSE)) {
if (r->parsed_uri.port_str) {
port_str = apr_pcalloc(p, strlen(r->parsed_uri.port_str) + 2);
port_str[0] = ':';
@@ -481,8 +491,16 @@ apr_status_t cache_generate_key_default(request_rec *r, apr_pool_t* p,
}
}
else {
- /* Use the server port */
- port_str = apr_psprintf(p, ":%u", ap_get_server_port(r));
+ if (conf->base_uri && conf->base_uri->port_str) {
+ port_str = conf->base_uri->port_str;
+ }
+ else if (conf->base_uri && conf->base_uri->hostname) {
+ port_str = "";
+ }
+ else {
+ /* Use the server port */
+ port_str = apr_psprintf(p, ":%u", ap_get_server_port(r));
+ }
}
/*