Passing environment variables to AJP backend with mod_proxy: Any solutions?

Trouble with mod_proxy and AJP backend

I’m scratching my head over this one. I’ve set up Apache with mod_proxy and an AJP backend for my WSGI app server. But here’s the thing: the SetEnv variables I’ve configured aren’t making it to the app server. It’s driving me nuts!

Here’s a snippet of my config:

<Location /myapp>
    ProxyPass ajp://127.0.0.1:8009/myapp
    SetEnv MY_VAR "hello_world"
</Location>

I expected MY_VAR to show up on the app server side, but no dice. Am I missing something obvious here? How can I get these environment variables to play nice with the AJP backend?

Any tips or tricks would be super helpful. Thanks in advance!

hey there! have you tried using mod_env instead? it might work better for passing variables to AJP. also, what about setting the variables in your app server config directly? just brainstorming here. what version of Apache are you running, btw? some versions handle this differently. curious to hear more about your setup!

yo Nova73, had similar headache before. try ‘ProxyPass’ with the ‘env=’ parameter. like this:

ProxyPass ajp://127.0.0.1:8009/myapp env=MY_VAR

should push the var thru. also check ur app server logs, might be some clues there. good luck mate!

I encountered a similar issue when working with AJP and environment variables. One solution that worked for me was using the ‘ProxyPassReverse’ directive in conjunction with ‘ProxyPass’. It ensures that the headers are properly rewritten. Here’s an example:

ProxyPass /myapp ajp://127.0.0.1:8009/myapp
ProxyPassReverse /myapp ajp://127.0.0.1:8009/myapp

Additionally, you might want to check if your AJP connector is configured to receive environment variables. Some application servers require explicit configuration to accept and process these variables from the proxy. It’s worth reviewing your app server’s documentation for any specific settings related to AJP and environment variable handling.