---- Igor Cicimov <icicimov@xxxxxxxxx> wrote: > On Mon, Dec 10, 2012 at 9:02 AM, <ohaya@xxxxxxx> wrote: > > > > > ---- Igor Cicimov <icicimov@xxxxxxxxx> wrote: > > > On Mon, Dec 10, 2012 at 7:19 AM, <ohaya@xxxxxxx> wrote: > > > > > > > Hi, > > > > > > > > We are trying to have an Apache (acting as a proxy) conditionally > > > > strip/remove a cookie from the incoming request, before it proxies the > > > > request. > > > > > > > > The condition is that, on the incoming request: > > > > > > > > - there is a specific HTTP header, MYHEADER, with a value of > > > > "MYHEADERVALUE", and > > > > - the root of the request URL's hostname (e.g., if hostname in the > > request > > > > URL is "www.foo.com", then root is ".foo.com") matches a certain > > string, > > > > e.g., ".whatever.com" > > > > > > > > If the conditions above are true, then we want to remove a cookie named > > > > "MYCOOKIE" from the incoming request, before forwarding the request > > onto > > > > the proxied host. > > > > > > > > I think that if the conditions match, according to this: > > > > > > > > > > http://stackoverflow.com/questions/1798431/how-to-remove-a-cookie-in-apache > > > > > > > > something like: > > > > > > > > RequestHeader add Cookie "MYCOOKIE='';expires='SOME_PAST_DATE'; > > > > Path=COOKIE_PATH" > > > > > > > > would remove the cookie, but I'm not sure how to construct the > > > > expression/expr that says something like this: > > > > > > > > <If hostname_root==whatever.com && MYHEADER=<some_string>> > > > > RequestHeader add Cookie "MYCOOKIE=';expires='SOME_PAST_DATE'; > > > > Path=COOKIE_PATH" > > > > </If> > > > > > > > > Also, I'm not sure what that "SOME_PAST_DATE" should be. > > > > > > > > Can anyone here tell me? > > > > > > > > Thanks, > > > > Jim > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx > > > > For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx > > > > > > > > > > > Use SetEnvIf > > > > > > Igor, > > > > I think that I can use SetEnvIf to set environment variables for each of > > the two conditions, but doesn't the RequestHeader directive only take only > > a single condition, e.g., "env=condition1"? > > > > Jim > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx > > For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx > > > > True, so how about this ... You set the cookie if "env = condition1" and > then edit/unset/merge/ or do whatever if "env != condition2" Hi, Thanks for the suggestion. I guess that I'd really rather not set the cookie then possibly have to unset it later. That seems a little too convoluted. What I was trying to find out with this post is about how something like SetEnvIfExpr: http://httpd.apache.org/docs/trunk/mod/mod_setenvif.html#setenvifexpr might be used. Apparently this SetEnvIfExpr is available in Apache 2.2.9+? That page has some examples of using SetEnvIfExpr, e.g.: SetEnvIfExpr "tolower(req('X-Sendfile')) == 'd:\images\very_big.iso')" iso_delivered plus, it links to this other page on expressions in Apache: http://httpd.apache.org/docs/trunk/expr.html which has examples of expressions: # Compare the host name to example.com and redirect to www.example.com if it matches <If "%{HTTP_HOST} == 'example.com'"> Redirect permanent / http://www.example.com </If> So I was thinking I could use something like that, but I'm not familiar with these "expressions", so I was hoping that someone here could tell me (or point the way to) the expression that I'd need to do what I described in my original post. Also, BTW, I'm having problems with what was suggested in the message thread on Stackoverflow.com in my original post. I tried the suggested RequestHeader, to try to remove a cookie in an incoming request, but it's not working. Rather it looks like it just replaces the entire "Cookie:" header altogether. FYI, for this testing, I have my Apache proxying (ProxyPass/ProxyPassReverse) a Tomcat instance. Thanks, Jim --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx