Apache 2.2 mod_headers: "RequestHeader edit" vs. environment variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

First of all, let me give you some context. The Apache 2.2's webpage
which describes mod_headers' "RequestHeader" directive says
(specifically for the "edit" action):

	RequestHeader edit header value replacement
[early|env=[!]variable]
	If this request header exists, its value is transformed
according to a regular expression search-and-replace. The value argument
is a regular expression, and the replacement is a replacement string,
which may contain backreferences. Both a value and a replacement are a
regular expression and a replacement string respectively.

That's fine, but I faced a situation in my production environment where
I had two JSESSIONIDs defined in the "Cookie" header (don't ask me why)
and this was confusing the load balancing algorithm
(mod_proxy_balancer). Without getting into too much details, what I had
to do was to clean up the "Cookie" header to leave there only the
JSESSIONID that I need. This is how I thought I could do that:

	SetEnvIf Cookie "JSESSIONID=([^;]+\.server.)" MYSESSIONID=$1
	RequestHeader edit Cookie "(^JSESSIONID=[^;]+; |;
JSESSIONID=[^;]+)" ""
	RequestHeader edit Cookie "(.*)" "$1;
JSESSIONID=%{MYSESSIONID}e" env=MYSESSIONID

The first two lines above work fine, but unfortunately the last one
doesn't because the "RequestHeader edit" directive cannot reference
environment variables in its replacement string (why?). :~(

If I understood correctly what the webpage mentioned above says, the
replacement string is just that (a fixed string) which may also contain
backreferences to groups in the value's regular expression, however,
since I was trying to append the content of an environment variable
there (in this case MYSESSIONID), I ended up with, for instance, the
following result (which is not what I wanted):

	Cookie: language=en;
JSESSIONID=KKb2Ry1NJTw8tWznLH2hLCkSTkq0nnyKwSys0MbSxLvymKb89Cgn!-2531024
50; customer_type=Residential; JSESSIONID=%{MYSESSIONID}e

I was looking for something like this:

	Cookie: language=en;
JSESSIONID=KKb2Ry1NJTw8tWznLH2hLCkSTkq0nnyKwSys0MbSxLvymKb89Cgn!-2531024
50; customer_type=Residential;
JSESSIONID=60685FA3BC4F0345196D00BFBFBFFC79.server2

Please, would it be possible to add this capability to the
"RequestHeader edit" directive so we would be able to use environments
variables inside the replacement string as well?

Thanks a lot!

PS: I'm running Apache 2.2.3 on RHEL 5.7


This e-mail (and attachment(s)) is confidential, proprietary, may be subject to copyright and legal privilege and no related rights are waived. If you are not the intended recipient or its agent, any review, dissemination, distribution or copying of this e-mail or any of its content is strictly prohibited and may be unlawful. All messages may be monitored as permitted by applicable law and regulations and our policies to protect our business. E-mails are not secure and you are deemed to have accepted any risk if you communicate with us by e-mail. If received in error, please notify us immediately and delete the e-mail (and any attachments) from any computer or any storage medium without printing a copy.

Ce courriel (ainsi que ses pièces jointes) est confidentiel, exclusif, et peut faire l’objet de droit d’auteur et de privilège juridique; aucun droit connexe n’est exclu. Si vous n’êtes pas le destinataire visé ou son représentant, toute étude, diffusion, transmission ou copie de ce courriel en tout ou en partie, est strictement interdite et peut être illégale. Tous les messages peuvent être surveillés, selon les lois et règlements applicables et les politiques de protection de notre entreprise. Les courriels ne sont pas sécurisés et vous êtes réputés avoir accepté tous les risques qui y sont liés si vous choisissez de communiquer avec nous par ce moyen. Si vous avez reçu ce message par erreur, veuillez nous en aviser immédiatement et supprimer ce courriel (ainsi que toutes ses pièces jointes) de tout ordinateur ou support de données sans en imprimer une copie. 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx





[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux