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

Reply via email to