Changes with Apache 2.0.31-dev
+
+ *) New Directive for mod_proxy: 'ProxyPreserveHost'. This passes
+ the incoming host header through to the proxied server
+ [Geoff <g.russell@ieee.org>]
+
*) New Directive Option for ProxyPass. It now can block a location
from being proxied [Jukka Pihl <jukka.pihl@entirem.com>]
<H2>Directives</H2>
<UL>
-<LI><A HREF="#proxyrequests">ProxyRequests</A>
-<LI><A HREF="#proxyremote">ProxyRemote</A>
-<LI><A HREF="#proxypass">ProxyPass</A>
-<LI><A HREF="#proxypassreverse">ProxyPassReverse</A>
-<LI><A HREF="#proxyblock">ProxyBlock</A>
<LI><A HREF="#allowconnect">AllowCONNECT</A>
-<LI><A HREF="#proxyreceivebuffersize">ProxyReceiveBufferSize</A>
-<LI><A HREF="#proxymaxforwards">ProxyMaxForwards</A>
<LI><A HREF="#noproxy">NoProxy</A>
+<LI><A HREF="#proxyblock">ProxyBlock</A>
<LI><A HREF="#proxydomain">ProxyDomain</A>
-<LI><A HREF="#proxyvia">ProxyVia</A>
<LI><A HREF="#proxyerroroverride">ProxyErrorOverride</A>
+<LI><A HREF="#proxymaxforwards">ProxyMaxForwards</A>
+<LI><A HREF="#proxypass">ProxyPass</A>
+<LI><A HREF="#proxypassreverse">ProxyPassReverse</A>
+<LI><A HREF="#proxypreservehost">ProxyPreserveHost</A>
+<LI><A HREF="#proxyreceivebuffersize">ProxyReceiveBufferSize</A>
+<LI><A HREF="#proxyremote">ProxyRemote</A>
+<LI><A HREF="#proxyrequests">ProxyRequests</A>
+<LI><A HREF="#proxyvia">ProxyVia</A>
</UL>
since the user's bookmark files will then contain fully qualified hosts.</P>
<HR>
+<H2><A NAME="proxyrequests">ProxyPreserveHost</A> directive</H2>
+<A
+ HREF="directive-dict.html#Syntax"
+ REL="Help"
+ ><STRONG>Syntax:</STRONG></A> ProxyPreserveHost on|off<BR>
+<A
+ HREF="directive-dict.html#Default"
+ REL="Help"
+><STRONG>Default:</STRONG></A> <CODE>ProxyPreserveHost Off</CODE><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> ProxyPreserveHost is only available in
+Apache 2.0.31 and later.<P>
+
+When enabled, this option will pass the Host: line from the incoming request to
+the proxied host, instead of the hostname specified in the proxypass line.
+</P>
+<P>This option should normally be turned 'off'.</P>
+
+<HR>
+
<H2><A NAME="proxyrequests">ProxyRequests</A> directive</H2>
<A
ps->maxfwd_set = 0;
ps->error_override = 0;
ps->error_override_set = 0;
+ ps->preserve_host_set =0;
+ ps->preserve_host =0;
return ps;
}
ps->recv_buffer_size = (overrides->recv_buffer_size_set == 0) ? base->recv_buffer_size : overrides->recv_buffer_size;
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;
return ps;
}
psf->error_override_set = 1;
return NULL;
}
+static const char *
+ set_preserve_host(cmd_parms *parms, void *dummy, int flag)
+{
+ proxy_server_conf *psf =
+ ap_get_module_config(parms->server->module_config, &proxy_module);
+
+ psf->preserve_host = flag;
+ psf->preserve_host_set = 1;
+ return NULL;
+}
static const char *
set_recv_buffer_size(cmd_parms *parms, void *dummy, const char *arg)
"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,
+ "on if we shoud preserve host header while proxying"),
+
{NULL}
};
*/
int error_override;
int error_override_set;
+ int preserve_host;
+ int preserve_host_set;
} proxy_server_conf;
buf = apr_pstrcat(p, r->method, " ", url, " HTTP/1.1" CRLF, NULL);
e = apr_bucket_pool_create(buf, strlen(buf), p);
APR_BRIGADE_INSERT_TAIL(bb, e);
- if (uri->port_str && uri->port != DEFAULT_HTTP_PORT) {
- buf = apr_pstrcat(p, "Host: ", uri->hostname, ":", uri->port_str, CRLF,
- NULL);
- e = apr_bucket_pool_create(buf, strlen(buf), p);
- APR_BRIGADE_INSERT_TAIL(bb, e);
- } else {
- buf = apr_pstrcat(p, "Host: ", uri->hostname, CRLF, NULL);
- e = apr_bucket_pool_create(buf, strlen(buf), p);
- APR_BRIGADE_INSERT_TAIL(bb, e);
+ if ( conf->preserve_host == 0 ) {
+ if (uri->port_str && uri->port != DEFAULT_HTTP_PORT) {
+ buf = apr_pstrcat(p, "Host: ", uri->hostname, ":", uri->port_str, CRLF,
+ NULL);
+ } else {
+ buf = apr_pstrcat(p, "Host: ", uri->hostname, CRLF, NULL);
+ }
+ }
+ else {
+ /* don't want to use r->hostname, as the incoming header might have a
+ * port attached
+ */
+ const char* hostname = apr_table_get(r->headers_in,"Host");
+ if (!hostname) {
+ hostname = r->server->server_hostname;
+ ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, r,
+ "proxy: no HTTP 0.9 request (with no host line) "
+ "on incoming request and preserve host set "
+ "forcing hostname to be %s for uri %s",
+ hostname,
+ r->uri );
+ }
+ buf = apr_pstrcat(p, "Host: ", hostname, CRLF, NULL);
}
+ e = apr_bucket_pool_create(buf, strlen(buf), p);
+ APR_BRIGADE_INSERT_TAIL(bb, e);
/* handle Via */
if (conf->viaopt == via_block) {