mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
Allow ProxyPreserveHost to work in <Proxy> sections
PR: 34901 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@824072 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -10,6 +10,9 @@ Changes with Apache 2.3.3
|
||||
mod_proxy_ftp: NULL pointer dereference on error paths.
|
||||
[Stefan Fritsch <sf fritsch.de>, Joe Orton]
|
||||
|
||||
*) Allow ProxyPreserveHost to work in <Proxy> sections. PR 34901.
|
||||
[Stefan Fritsch]
|
||||
|
||||
*) configure: Fix THREADED_MPMS so that mod_cgid is enabled again
|
||||
for worker MPM. [Takashi Sato]
|
||||
|
||||
|
@@ -412,6 +412,7 @@ request</description>
|
||||
<syntax>ProxyPreserveHost On|Off</syntax>
|
||||
<default>ProxyPreserveHost Off</default>
|
||||
<contextlist><context>server config</context><context>virtual host</context>
|
||||
<context>directory</context>
|
||||
</contextlist>
|
||||
<compatibility>Available in Apache 2.0.31 and later.</compatibility>
|
||||
|
||||
|
@@ -200,15 +200,17 @@
|
||||
* param to ap_wait_or_timeout()
|
||||
* 20090925.1 (2.3.3-dev) Add optional function ap_logio_get_last_bytes() to
|
||||
* mod_logio
|
||||
* 20091011.0 (2.3.3-dev) Move preserve_host{,_set} from proxy_server_conf to
|
||||
* proxy_dir_conf
|
||||
*
|
||||
*/
|
||||
|
||||
#define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
|
||||
|
||||
#ifndef MODULE_MAGIC_NUMBER_MAJOR
|
||||
#define MODULE_MAGIC_NUMBER_MAJOR 20090925
|
||||
#define MODULE_MAGIC_NUMBER_MAJOR 20091011
|
||||
#endif
|
||||
#define MODULE_MAGIC_NUMBER_MINOR 1 /* 0...n */
|
||||
#define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */
|
||||
|
||||
/**
|
||||
* Determine if the server's current MODULE_MAGIC_NUMBER is at least a
|
||||
|
@@ -1103,8 +1103,6 @@ static void * create_proxy_config(apr_pool_t *p, server_rec *s)
|
||||
ps->maxfwd_set = 0;
|
||||
ps->error_override = 0;
|
||||
ps->error_override_set = 0;
|
||||
ps->preserve_host_set = 0;
|
||||
ps->preserve_host = 0;
|
||||
ps->timeout = 0;
|
||||
ps->timeout_set = 0;
|
||||
ps->badopt = bad_error;
|
||||
@@ -1144,8 +1142,6 @@ static void * merge_proxy_config(apr_pool_t *p, void *basev, void *overridesv)
|
||||
ps->maxfwd_set = overrides->maxfwd_set || base->maxfwd_set;
|
||||
ps->error_override = (overrides->error_override_set == 0) ? base->error_override : overrides->error_override;
|
||||
ps->error_override_set = overrides->error_override_set || base->error_override_set;
|
||||
ps->preserve_host = (overrides->preserve_host_set == 0) ? base->preserve_host : overrides->preserve_host;
|
||||
ps->preserve_host_set = overrides->preserve_host_set || base->preserve_host_set;
|
||||
ps->timeout= (overrides->timeout_set == 0) ? base->timeout : overrides->timeout;
|
||||
ps->timeout_set = overrides->timeout_set || base->timeout_set;
|
||||
ps->badopt = (overrides->badopt_set == 0) ? base->badopt : overrides->badopt;
|
||||
@@ -1169,6 +1165,8 @@ static void *create_proxy_dir_config(apr_pool_t *p, char *dummy)
|
||||
new->cookie_domains = apr_array_make(p, 10, sizeof(struct proxy_alias));
|
||||
new->cookie_path_str = apr_strmatch_precompile(p, "path=", 0);
|
||||
new->cookie_domain_str = apr_strmatch_precompile(p, "domain=", 0);
|
||||
new->preserve_host_set = 0;
|
||||
new->preserve_host = 0;
|
||||
new->interpolate_env = -1; /* unset */
|
||||
|
||||
return (void *) new;
|
||||
@@ -1197,6 +1195,9 @@ static void *merge_proxy_dir_config(apr_pool_t *p, void *basev, void *addv)
|
||||
new->ftp_directory_charset = add->ftp_directory_charset ?
|
||||
add->ftp_directory_charset :
|
||||
base->ftp_directory_charset;
|
||||
new->preserve_host = (add->preserve_host_set == 0) ? base->preserve_host
|
||||
: add->preserve_host;
|
||||
new->preserve_host_set = add->preserve_host_set || base->preserve_host_set;
|
||||
return new;
|
||||
}
|
||||
|
||||
@@ -1612,13 +1613,12 @@ static const char *
|
||||
return NULL;
|
||||
}
|
||||
static const char *
|
||||
set_preserve_host(cmd_parms *parms, void *dummy, int flag)
|
||||
set_preserve_host(cmd_parms *parms, void *dconf, int flag)
|
||||
{
|
||||
proxy_server_conf *psf =
|
||||
ap_get_module_config(parms->server->module_config, &proxy_module);
|
||||
proxy_dir_conf *conf = dconf;
|
||||
|
||||
psf->preserve_host = flag;
|
||||
psf->preserve_host_set = 1;
|
||||
conf->preserve_host = flag;
|
||||
conf->preserve_host_set = 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -2115,7 +2115,7 @@ static const command_rec proxy_cmds[] =
|
||||
"Configure Via: proxy header header to one of: on | off | block | full"),
|
||||
AP_INIT_FLAG("ProxyErrorOverride", set_proxy_error_override, NULL, RSRC_CONF,
|
||||
"use our error handling pages instead of the servers' we are proxying"),
|
||||
AP_INIT_FLAG("ProxyPreserveHost", set_preserve_host, NULL, RSRC_CONF,
|
||||
AP_INIT_FLAG("ProxyPreserveHost", set_preserve_host, NULL, RSRC_CONF|ACCESS_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. "
|
||||
|
@@ -160,8 +160,6 @@ typedef struct {
|
||||
*/
|
||||
int error_override;
|
||||
int error_override_set;
|
||||
int preserve_host;
|
||||
int preserve_host_set;
|
||||
apr_interval_time_t timeout;
|
||||
char timeout_set;
|
||||
enum {
|
||||
@@ -203,6 +201,8 @@ typedef struct {
|
||||
const apr_strmatch_pattern* cookie_domain_str;
|
||||
const char *ftp_directory_charset;
|
||||
int interpolate_env;
|
||||
int preserve_host;
|
||||
int preserve_host_set;
|
||||
} proxy_dir_conf;
|
||||
|
||||
/* if we interpolate env vars per-request, we'll need a per-request
|
||||
|
@@ -693,7 +693,9 @@ int ap_proxy_http_request(apr_pool_t *p, request_rec *r,
|
||||
apr_off_t bytes;
|
||||
int force10, rv;
|
||||
apr_table_t *headers_in_copy;
|
||||
proxy_dir_conf *dconf;
|
||||
|
||||
dconf = ap_get_module_config(r->per_dir_config, &proxy_module);
|
||||
header_brigade = apr_brigade_create(p, origin->bucket_alloc);
|
||||
|
||||
/*
|
||||
@@ -723,7 +725,7 @@ int ap_proxy_http_request(apr_pool_t *p, request_rec *r,
|
||||
ap_xlate_proto_to_ascii(buf, strlen(buf));
|
||||
e = apr_bucket_pool_create(buf, strlen(buf), p, c->bucket_alloc);
|
||||
APR_BRIGADE_INSERT_TAIL(header_brigade, e);
|
||||
if (conf->preserve_host == 0) {
|
||||
if (dconf->preserve_host == 0) {
|
||||
if (ap_strchr_c(uri->hostname, ':')) { /* if literal IPv6 address */
|
||||
if (uri->port_str && uri->port != DEFAULT_HTTP_PORT) {
|
||||
buf = apr_pstrcat(p, "Host: [", uri->hostname, "]:",
|
||||
|
Reference in New Issue
Block a user