Discussion:
mod_rewrite/mod_header/mod_proxy problem
Josh Konkol
2003-03-10 17:01:29 UTC
Permalink
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-***@httpd.apache.org
" from the digest: users-digest-***@httpd.apache.org
For additional commands, e-mail: users-***@httpd.apache.org
Bill Stoddard
2003-03-10 17:16:25 UTC
Permalink
Post by Josh Konkol
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.
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
Josh Konkol
2003-03-10 19:46:19 UTC
Permalink
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
Post by Bill Stoddard
Post by Josh Konkol
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.
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
Bill Stoddard
2003-03-10 21:23:58 UTC
Permalink
Post by Josh Konkol
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
Josh Konkol
2003-03-11 15:55:29 UTC
Permalink
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 ??
Post by Bill Stoddard
Post by Josh Konkol
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
Bill Stoddard
2003-03-13 20:04:16 UTC
Permalink
Post by Josh Konkol
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

Kwindla Hultman Kramer
2003-03-10 17:22:56 UTC
Permalink
Post by Josh Konkol
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
Josh Konkol
2003-03-10 17:34:43 UTC
Permalink
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
Post by Kwindla Hultman Kramer
Post by Josh Konkol
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
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-***@httpd.apache.org
" from the digest: users-digest-***@httpd.apache.org
For additional commands, e-mail: users-***@httpd.apache.org
Josh Konkol
2003-03-10 17:51:54 UTC
Permalink
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
Post by Josh Konkol
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.
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
---------------------------------------------------------------------
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-***@httpd.apache.org
" from the digest: users-digest-***@httpd.apache.org
For additional commands, e-mail: users-***@httpd.apache.org
Loading...