You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ia...@apache.org on 2002/01/29 22:08:37 UTC
cvs commit: httpd-2.0/modules/proxy mod_proxy.c mod_proxy.h proxy_http.c
ianh 02/01/29 13:08:37
Modified: docs/manual/mod mod_proxy.html
. CHANGES
modules/proxy mod_proxy.c mod_proxy.h proxy_http.c
Log:
new directive 'ProxyPreserveHost' which allows the incoming host line to
be sent to the proxied server.
Submitted by: g.russell@ieee.org (1.3 version)
Reviewed by: Ian Holsman/Graham Legget/Chuck Murcko
Revision Changes Path
1.69 +47 -8 httpd-2.0/docs/manual/mod/mod_proxy.html
Index: mod_proxy.html
===================================================================
RCS file: /home/cvs/httpd-2.0/docs/manual/mod/mod_proxy.html,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- mod_proxy.html 29 Jan 2002 19:33:25 -0000 1.68
+++ mod_proxy.html 29 Jan 2002 21:08:37 -0000 1.69
@@ -72,18 +72,19 @@
<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>
@@ -222,6 +223,44 @@
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
1.546 +5 -0 httpd-2.0/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/httpd-2.0/CHANGES,v
retrieving revision 1.545
retrieving revision 1.546
diff -u -r1.545 -r1.546
--- CHANGES 29 Jan 2002 19:00:44 -0000 1.545
+++ CHANGES 29 Jan 2002 21:08:37 -0000 1.546
@@ -1,4 +1,9 @@
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....@ieee.org>]
+
*) New Directive Option for ProxyPass. It now can block a location
from being proxied [Jukka Pihl <ju...@entirem.com>]
1.67 +16 -0 httpd-2.0/modules/proxy/mod_proxy.c
Index: mod_proxy.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/proxy/mod_proxy.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -r1.66 -r1.67
--- mod_proxy.c 29 Jan 2002 19:00:45 -0000 1.66
+++ mod_proxy.c 29 Jan 2002 21:08:37 -0000 1.67
@@ -492,6 +492,8 @@
ps->maxfwd_set = 0;
ps->error_override = 0;
ps->error_override_set = 0;
+ ps->preserve_host_set =0;
+ ps->preserve_host =0;
return ps;
}
@@ -515,6 +517,7 @@
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;
}
@@ -780,6 +783,16 @@
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)
@@ -953,6 +966,9 @@
"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}
};
1.68 +2 -0 httpd-2.0/modules/proxy/mod_proxy.h
Index: mod_proxy.h
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/proxy/mod_proxy.h,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- mod_proxy.h 3 Jan 2002 20:42:08 -0000 1.67
+++ mod_proxy.h 29 Jan 2002 21:08:37 -0000 1.68
@@ -187,6 +187,8 @@
*/
int error_override;
int error_override_set;
+ int preserve_host;
+ int preserve_host_set;
} proxy_server_conf;
1.124 +25 -9 httpd-2.0/modules/proxy/proxy_http.c
Index: proxy_http.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_http.c,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -r1.123 -r1.124
--- proxy_http.c 27 Jan 2002 12:52:07 -0000 1.123
+++ proxy_http.c 29 Jan 2002 21:08:37 -0000 1.124
@@ -488,16 +488,32 @@
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) {