You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modproxy-dev@apache.org by Josh Konkol <jk...@guidemail.com> on 2003/03/10 18:01:29 UTC

mod_rewrite/mod_header/mod_proxy problem

Dear Apache Guru's I need your help!!

What I need to do is take the key:values in a cookie and turn them into 
http headers.  Using a combination of mod_rewrite, mod_header & mod_proxy 
I've come up with a solution but the headers aren't being created.

Here's what I have in my httpd.conf file:

RewriteEngine on
RewriteLog "/tmp/rewrite.log"
RewriteLogLevel 9
RewriteRule ^(.*)&(.*)$ $1&$2 [S=1]
RewriteRule (.*) $1&%{HTTP_COOKIE}
# If there's a '; ' then there is more than one variable left
RewriteRule  ^(.*);.(.*)=(.*)$ $1 [E=$2:$3,N]
# Now there's only one variable left
RewriteRule  ^(.*)&(.*)=(.*)$ $1 [E=$2:$3]
RewriteRule ^(.*)&$ $1
RewriteRule ^/(.*)$ /done$1 [R]

Header add sm_user "%{smuser}e" env=smuser
Header add goHierId %{goHierId}e env=goHierId
Header add sessionid %{sessionid}e env=sessionid
Header add foo "bar"

ProxyPass       /doneHomeCostEstimator   
http://wsapp01t.guidehome.com/HomeCostEstimator
ProxyPassReverse       /doneHomeCostEstimator      
http://wsapp01t.guidehome.com/HomeCostEstimator

The page I'm directing to is a .jsp which displays the set http headers 
and the sm_user & goHierId don't show up there.  

Is there any issue with setting a http header with mod_header and then 
proxying that request ??

Any help is appreciated !!!!

Josh


Re: mod_rewrite/mod_header/mod_proxy problem

Posted by Josh Konkol <jk...@guidemail.com>.
Ok here is an update !!  Thanks to Kwin's input I started looking more 
closely at what I am trying to do.  If i use the RequestHeader directive 
instead of the Header directive I can see the http headers created on my 
.jsp page, but they end up with NULL values because RequestHeader does 
NOT accept the %{env}e environment variable as a value.

Anyone have any ideas on how I can overcome this ?

Thanks in advance !!

Josh

Josh Konkol <jk...@guidemail.com> wrote in
news:Xns933A7042CDBF0jkonkolguidemailcom@80.91.224.249: 

> Dear Apache Guru's I need your help!!
> 
> What I need to do is take the key:values in a cookie and turn them
> into http headers.  Using a combination of mod_rewrite, mod_header &
> mod_proxy I've come up with a solution but the headers aren't being
> created. 
> 
> Here's what I have in my httpd.conf file:
> 
> RewriteEngine on
> RewriteLog "/tmp/rewrite.log"
> RewriteLogLevel 9
> RewriteRule ^(.*)&(.*)$ $1&$2 [S=1]
> RewriteRule (.*) $1&%{HTTP_COOKIE}
> # If there's a '; ' then there is more than one variable left
> RewriteRule  ^(.*);.(.*)=(.*)$ $1 [E=$2:$3,N]
> # Now there's only one variable left
> RewriteRule  ^(.*)&(.*)=(.*)$ $1 [E=$2:$3]
> RewriteRule ^(.*)&$ $1
> RewriteRule ^/(.*)$ /done$1 [R]
> 
> Header add sm_user "%{smuser}e" env=smuser
> Header add goHierId %{goHierId}e env=goHierId
> Header add sessionid %{sessionid}e env=sessionid
> Header add foo "bar"
> 
> ProxyPass       /doneHomeCostEstimator   
> http://wsapp01t.guidehome.com/HomeCostEstimator
> ProxyPassReverse       /doneHomeCostEstimator      
> http://wsapp01t.guidehome.com/HomeCostEstimator
> 
> The page I'm directing to is a .jsp which displays the set http
> headers and the sm_user & goHierId don't show up there.  
> 
> Is there any issue with setting a http header with mod_header and then
> proxying that request ??
> 
> Any help is appreciated !!!!
> 
> Josh
> 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server
> Project. See <URL:http://httpd.apache.org/userslist.html> for more
> info. To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
> 



[users@httpd] Re: mod_rewrite/mod_header/mod_proxy problem

Posted by Josh Konkol <sa...@guidemail.com>.
Kwin,

Thanks for the quick response !!  Problem is I am using Apache/2.0.44
not 1.3.  Have you had any experience with 2 or where the issues fixed
in that version ? 

Josh

Kwindla Hultman Kramer <kw...@allafrica.com> wrote in
news:15980.51696.619781.290530@thel.allafrica.com: 

> 
> Josh Konkol writes:
> 
> > Is there any issue with setting a http header with mod_header and
> > then proxying that request ??
> 
> Assuming you're using Apache 1.3, there is an issue: mod_header and
> mod_proxy don't play well together.
> 
> I maintain a set of patches that provide some header-manipulation
> directives for 1.3.x mod_proxy:
> 
>   http://allafrica.com/tools/apache/mod_proxy/
> 
> By the way, your cookie-deconstructing rewrite rules are pretty slick!
> 
> Yours,
> Kwin
> 



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: mod_rewrite/mod_header/mod_proxy problem

Posted by Josh Konkol <sa...@guidemail.com>.
Kwin,

Thanks for the quick response !!  Problem is I am using Apache/2.0.44
not 1.3.  Have you had any experience with 2 or where the issues fixed
in that version ? 

Josh

Kwindla Hultman Kramer <kw...@allafrica.com> wrote in
news:15980.51696.619781.290530@thel.allafrica.com: 

> 
> Josh Konkol writes:
> 
> > Is there any issue with setting a http header with mod_header and
> > then proxying that request ??
> 
> Assuming you're using Apache 1.3, there is an issue: mod_header and
> mod_proxy don't play well together.
> 
> I maintain a set of patches that provide some header-manipulation
> directives for 1.3.x mod_proxy:
> 
>   http://allafrica.com/tools/apache/mod_proxy/
> 
> By the way, your cookie-deconstructing rewrite rules are pretty slick!
> 
> Yours,
> Kwin
> 



Re: mod_rewrite/mod_header/mod_proxy problem

Posted by Kwindla Hultman Kramer <kw...@allafrica.com>.
Josh Konkol writes:

 > Is there any issue with setting a http header with mod_header and then 
 > proxying that request ??

Assuming you're using Apache 1.3, there is an issue: mod_header and
mod_proxy don't play well together.

I maintain a set of patches that provide some header-manipulation
directives for 1.3.x mod_proxy:

  http://allafrica.com/tools/apache/mod_proxy/

By the way, your cookie-deconstructing rewrite rules are pretty slick!

Yours,
Kwin

Re: mod_rewrite/mod_header/mod_proxy problem

Posted by Bill Stoddard <bi...@wstoddard.com>.
Josh Konkol wrote:
> Once again Bill is correct.  
> 
> If I use setenv to set an environment variable it works.   What doesn't 
> appear to work are the environment variables set from [e=key:value] on a 
> rewriterule line.  I can see the value being set in the rewrite log.  
> 
> Any ideas ??
> 

Nothing obvious jumps out at me. I don't have a lot of time to spend on 
this now so you should probably open a PR in bugzilla and include a very 
simple test case demonstrating the failure. Someone will eventually get 
around to debugging it.

Bill


Re: mod_rewrite/mod_header/mod_proxy problem

Posted by Josh Konkol <sa...@guidemail.com>.
Once again Bill is correct.  

If I use setenv to set an environment variable it works.   What doesn't 
appear to work are the environment variables set from [e=key:value] on a 
rewriterule line.  I can see the value being set in the rewrite log.  

Any ideas ??

Bill Stoddard <bi...@wstoddard.com> wrote in
news:3E6D026E.3050507@wstoddard.com: 

> Josh Konkol wrote:
>> Thanks Bill you are correct.  I changed it to RequestHeader and now I
>> can see the headers being created.  Problem is RequestHeader doesn't
>> accept the ${env}e value and instead puts in a <null> value. >
>> Any ideas ??
> 
> Sure it does (perhaps the doc is wrong). I've tested this recently and
> it works fine.
> 
>     RequestHeader append SSL_SESSION_ID %{SSL_SESSION_ID}e
>     RequestHeader append SSL_VERSION_INTERFACE
>     %{SSL_VERSION_INTERFACE}e RequestHeader append SSL_CIPHER
>     %{SSL_CIPHER}e RequestHeader append SSL_SERVER_S_DN
>     %{SSL_SERVER_S_DN}e RequestHeader append SSL_CIPHER_USEKEYSIZE
>     %{SSL_CIPHER_USEKEYSIZE}e 
> 
> Bill
> 
> 



Re: mod_rewrite/mod_header/mod_proxy problem

Posted by Bill Stoddard <bi...@wstoddard.com>.
Josh Konkol wrote:
> Thanks Bill you are correct.  I changed it to RequestHeader and now I can 
> see the headers being created.  Problem is RequestHeader doesn't accept 
> the ${env}e value and instead puts in a <null> value. >
> Any ideas ??

Sure it does (perhaps the doc is wrong). I've tested this recently and 
it works fine.

    RequestHeader append SSL_SESSION_ID %{SSL_SESSION_ID}e
    RequestHeader append SSL_VERSION_INTERFACE %{SSL_VERSION_INTERFACE}e
    RequestHeader append SSL_CIPHER %{SSL_CIPHER}e
    RequestHeader append SSL_SERVER_S_DN %{SSL_SERVER_S_DN}e
    RequestHeader append SSL_CIPHER_USEKEYSIZE %{SSL_CIPHER_USEKEYSIZE}e

Bill


Re: mod_rewrite/mod_header/mod_proxy problem

Posted by Josh Konkol <jk...@guidemail.com>.
Thanks Bill you are correct.  I changed it to RequestHeader and now I can 
see the headers being created.  Problem is RequestHeader doesn't accept 
the ${env}e value and instead puts in a <null> value.

Any ideas ??

Josh

Bill Stoddard <bi...@wstoddard.com> wrote in
news:3E6CC869.3030708@wstoddard.com: 

> Josh Konkol wrote:
>> Dear Apache Guru's I need your help!!
>> 
>> What I need to do is take the key:values in a cookie and turn them
>> into http headers.  Using a combination of mod_rewrite, mod_header &
>> mod_proxy I've come up with a solution but the headers aren't being
>> created. 
>> 
>> Here's what I have in my httpd.conf file:
>> 
>> RewriteEngine on
>> RewriteLog "/tmp/rewrite.log"
>> RewriteLogLevel 9
>> RewriteRule ^(.*)&(.*)$ $1&$2 [S=1]
>> RewriteRule (.*) $1&%{HTTP_COOKIE}
>> # If there's a '; ' then there is more than one variable left
>> RewriteRule  ^(.*);.(.*)=(.*)$ $1 [E=$2:$3,N]
>> # Now there's only one variable left
>> RewriteRule  ^(.*)&(.*)=(.*)$ $1 [E=$2:$3]
>> RewriteRule ^(.*)&$ $1
>> RewriteRule ^/(.*)$ /done$1 [R]
>> 
>> Header add sm_user "%{smuser}e" env=smuser
>> Header add goHierId %{goHierId}e env=goHierId
>> Header add sessionid %{sessionid}e env=sessionid
>> Header add foo "bar"
>> 
>> ProxyPass       /doneHomeCostEstimator   
>> http://wsapp01t.guidehome.com/HomeCostEstimator
>> ProxyPassReverse       /doneHomeCostEstimator      
>> http://wsapp01t.guidehome.com/HomeCostEstimator
>> 
>> The page I'm directing to is a .jsp which displays the set http
>> headers and the sm_user & goHierId don't show up there.  
>> 
>> Is there any issue with setting a http header with mod_header and
>> then proxying that request ??
>> 
>> Any help is appreciated !!!!
>> 
>> Josh
>> 
> 
> The Header directive will only add headers to the response.  Check out
> the "RequestHeader append" directive in Apache httpd 2.0.
> 
> Bill
> 
> 



Re: mod_rewrite/mod_header/mod_proxy problem

Posted by Bill Stoddard <bi...@wstoddard.com>.
Josh Konkol wrote:
> Dear Apache Guru's I need your help!!
> 
> What I need to do is take the key:values in a cookie and turn them into 
> http headers.  Using a combination of mod_rewrite, mod_header & mod_proxy 
> I've come up with a solution but the headers aren't being created.
> 
> Here's what I have in my httpd.conf file:
> 
> RewriteEngine on
> RewriteLog "/tmp/rewrite.log"
> RewriteLogLevel 9
> RewriteRule ^(.*)&(.*)$ $1&$2 [S=1]
> RewriteRule (.*) $1&%{HTTP_COOKIE}
> # If there's a '; ' then there is more than one variable left
> RewriteRule  ^(.*);.(.*)=(.*)$ $1 [E=$2:$3,N]
> # Now there's only one variable left
> RewriteRule  ^(.*)&(.*)=(.*)$ $1 [E=$2:$3]
> RewriteRule ^(.*)&$ $1
> RewriteRule ^/(.*)$ /done$1 [R]
> 
> Header add sm_user "%{smuser}e" env=smuser
> Header add goHierId %{goHierId}e env=goHierId
> Header add sessionid %{sessionid}e env=sessionid
> Header add foo "bar"
> 
> ProxyPass       /doneHomeCostEstimator   
> http://wsapp01t.guidehome.com/HomeCostEstimator
> ProxyPassReverse       /doneHomeCostEstimator      
> http://wsapp01t.guidehome.com/HomeCostEstimator
> 
> The page I'm directing to is a .jsp which displays the set http headers 
> and the sm_user & goHierId don't show up there.  
> 
> Is there any issue with setting a http header with mod_header and then 
> proxying that request ??
> 
> Any help is appreciated !!!!
> 
> Josh
> 

The Header directive will only add headers to the response.  Check out 
the "RequestHeader append" directive in Apache httpd 2.0.

Bill


[users@httpd] Re: mod_rewrite/mod_header/mod_proxy problem

Posted by Josh Konkol <jk...@guidemail.com>.
Ok here is an update !!  Thanks to Kwin's input I started looking more 
closely at what I am trying to do.  If i use the RequestHeader directive 
instead of the Header directive I can see the http headers created on my 
.jsp page, but they end up with NULL values because RequestHeader does 
NOT accept the %{env}e environment variable as a value.

Anyone have any ideas on how I can overcome this ?

Thanks in advance !!

Josh

Josh Konkol <jk...@guidemail.com> wrote in
news:Xns933A7042CDBF0jkonkolguidemailcom@80.91.224.249: 

> Dear Apache Guru's I need your help!!
> 
> What I need to do is take the key:values in a cookie and turn them
> into http headers.  Using a combination of mod_rewrite, mod_header &
> mod_proxy I've come up with a solution but the headers aren't being
> created. 
> 
> Here's what I have in my httpd.conf file:
> 
> RewriteEngine on
> RewriteLog "/tmp/rewrite.log"
> RewriteLogLevel 9
> RewriteRule ^(.*)&(.*)$ $1&$2 [S=1]
> RewriteRule (.*) $1&%{HTTP_COOKIE}
> # If there's a '; ' then there is more than one variable left
> RewriteRule  ^(.*);.(.*)=(.*)$ $1 [E=$2:$3,N]
> # Now there's only one variable left
> RewriteRule  ^(.*)&(.*)=(.*)$ $1 [E=$2:$3]
> RewriteRule ^(.*)&$ $1
> RewriteRule ^/(.*)$ /done$1 [R]
> 
> Header add sm_user "%{smuser}e" env=smuser
> Header add goHierId %{goHierId}e env=goHierId
> Header add sessionid %{sessionid}e env=sessionid
> Header add foo "bar"
> 
> ProxyPass       /doneHomeCostEstimator   
> http://wsapp01t.guidehome.com/HomeCostEstimator
> ProxyPassReverse       /doneHomeCostEstimator      
> http://wsapp01t.guidehome.com/HomeCostEstimator
> 
> The page I'm directing to is a .jsp which displays the set http
> headers and the sm_user & goHierId don't show up there.  
> 
> Is there any issue with setting a http header with mod_header and then
> proxying that request ??
> 
> Any help is appreciated !!!!
> 
> Josh
> 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server
> Project. See <URL:http://httpd.apache.org/userslist.html> for more
> info. To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
> 



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org