Re: Copying environment variables

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

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

All,

On 6/30/20 11:20, Christopher Schultz wrote:
> All,
>
> Is it possible to "copy" an environment variable to another name?
> Something like this:
>
> SetEnv foo "bar" SetEnv baz ${foo}e
>
> Now, "baz" has value "bar".
>
> It doesn't appear to work as written above, but the documentation
> doesn't actually suggest you can do that kind of thing.
>
> I have an environment variable whose value I need to copy into
> another name. What are my options for doing that kind of thing?

Actually, this is probably a very important clarification, so let me
explain exactly what I'm trying to do.

I'm working on BZ 64338 [1] which adds a new environment variable to
mod_proxy_balancer: BALANCER_PROXY_STATUS.

I'd like to forward that value over to Tomcat using mod_proxy_ajp.
mod_proxy_ajp will automatically forward any environment variable
called AJP_* across the wire to Tomcat. So I was hoping to do
something like this:

SetEnv AJP_BALANCER_WORKER_STATUS %{BALANCER_WORKER_STATUS}e

That doesn't work -- I get a literal ${BALANCER_WORKER_STATUS}e as my
value in Tomcat, so I tried this as well:

RewriteRule .* -
[E=AJP_BALANCER_WORKER_STATUS:%{ENV:BALANCER_WORKER_STATUS}]

This doesn't seem to send anything over, and Tomcat sees nothing.

I also tried this, since eventually I won't be using mod_proxy_ajp but
mod_proxy_http:

RequestHeader set test_ajp_balancer_worker_status
%{BALANCER_WORKER_STATUS}e

I can see the HTTP header on the Tomcat side, but its value is null.

I've put the BALANCER_WORKER_STATUS environment variable into the
access-log and I can see that it's got a value ("1"), so I'm guessing
that the environment variable is established in mod_proxy_balancer so
late in the process that neither RewriteRule nor RquestHeader have a
chance to see a real value, there.

I have altered my code to set both BALANCER_WORKER_STATUS *and*
AJP_BALANCER_WORKER_STATUS and there I can see the value being
sent-over the wire to Tomcat.

The primary use-case for this BALANCER_WORKER_STATUS value is to send
over the wire to the origin server, so what's the best thing for me to
do, here? For mod_proxy_ajp I can either have mod_proxy_balancer set
the AJP_ environment variable (or I suppose mod_proxy_ajp could *copy*
that variable, or use its value as-is which would probably be better),
but how should mod_proxy_http handle this? HTTP headers are really the
only way to communicate this kind of information to the back-end
server and "RequestHeader" isn't able to pick this up.

Does it need direct-support from mod_proxy instead of trying to cobble
the pieces together from BZ 64338 and other existing directives? My
goal with 64388 was to write the smallest patch that could get the job
done, but I'm not sure it's possible do to it in this way.

Thanks,
- -chris

[1] https://bz.apache.org/bugzilla/show_bug.cgi?id=64338
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl77XQQACgkQHPApP6U8
pFhcphAAy34KXHNi0gUberEHoS0ZAl4czwTddTpWDTuUtVZUtxP5EEoZVgrXNOmv
U6TlNMnjoY2Ea43/gpbblDLbgpaAndqwU0QOW8sQlRvs8an0Kz19Y670GPHPvhXL
xnnVr992CbBDaUhLxxZVMLPZzCte7pScimk65KTa9ZF2a6Chp6FhTtgZDH4OVrP/
vRRhxLcFv1m3WGL1MiUKpqwgLg+GoXN5pl4yWX+nyZLHvOoKDn7FxENw64FSG0nE
AEgzNNCrYOGFzjPqqEhk+oc+4E0kjODGjtN0F5S30n+Fr/q1YUi6RYK8iaArFHit
lEv/bfQZCIyZojqTfzdSQZISmbdgIambRULEAq5nFgzSYaZFWCSGmzECoKHa1Lj/
g1lIch4+E2rlEapvjmcRiWfXjY27VzadboeVEEHcDpR/M2E+H5LW0AJnWeK7EoSx
u+Q34qVIkdkzmW4N4ZcuWST0PFRwZ+yp6j2LE+O8rKuQlJJKsNPxUBApFYtCfXZg
8/27EQIpeP94+CzphmLd3LYcn8Ipot82HIQYGnQ4Gis6fJ/vjOHG0SjEBnxQQPhq
vaF19uw3ITBwitcF3ZG1P0iHd6OYx5M7Luicj2zXrwcaYfhP26hoKqAMtyYdE9/C
GW8JcCkDi29uEb3E7kzMiLvXf5MBSleDikAIGNJbsByLdmFbcME=
=t3xJ
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
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