You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Brian Akins <br...@turner.com> on 2005/12/20 21:31:31 UTC
[PATCH] override Host in proxy_http based on env
I have a few strange situations where I need to have a completely
different Host header for some 2nd tier servers, but preserve host
doesn't help.
This simple patch allows one to change the Host: header sent to origin's
using the "proxy-host" env. It only works when preserve host is off.
Sorry most of it is format changes after adding the aditional if.
--- mod_proxy_http.c.bak 2005-12-20 15:25:13.000000000 -0500
+++ mod_proxy_http.c 2005-12-20 15:26:45.000000000 -0500
@@ -635,11 +635,16 @@
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 (uri->port_str && uri->port != DEFAULT_HTTP_PORT) {
- buf = apr_pstrcat(p, "Host: ", uri->hostname, ":",
uri->port_str,
- CRLF, NULL);
- } else {
+ const char* hostname = apr_table_get(r->subprocess_env,
"proxy-host");
+ if(hostname) {
buf = apr_pstrcat(p, "Host: ", hostname, CRLF, NULL);
+ } else {
+ 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 {
--
Brian Akins
Lead Systems Engineer
CNN Internet Technologies