Forum Moderators: phranque

Message Too Old, No Replies

using modSetEnvIf in combination with mod jk

controlling how Apache delegates requests to application servers ...

         

jnsunkersett

5:26 pm on Feb 12, 2011 (gmt 0)

10+ Year Member



Hi,

I have configured my Apache web server to use mod_jk and front my application server (Jboss), running on port 8080.

So users access http:// mymachine.mydomain.com (port 80 by default) but the request is served by Jboss running on port 8080.

I have 2 Jboss app servers but a single Apache server

I know by using mod_jk & wroker.properties & the related works, the incoming load of requests can be balanced between the 2 JBoss servers.

But my intention is different. (it is not load balancing) and today, I came to know about mod_SetEnvIf.

Is it possible to combine mod_SetEnvIf & mod_jk ?

If not combine use mod_SetEnvIf instead of mod_jk to control how Apache delegates the request further to be serviced.

Using mod_SetEnvIf, I think I can check the Remote_Addr of the incoming client requests;
  • if it is from a particular set of IP's (say 10.1.5.*), I want it so delegated so as to be be served by Jboss-One

  • and if coming from another set (say 10.1.7.*) it should be served by Jboss-Two.


JBoss-One is a DEV server and Jboss-TWO is QA server (running my application released to QA)

This is so because my single Apache server is hosted and publicly listed on the internet/ WWW (which is prerequisite of one of the features in my application)....(and do not have the budget to put up register a new domain for QA)

I have posted similar (but maybe with lesser detail) queries on ApacheLounge but have received no replies.

[apachelounge.com...]

Today I read about mod_SetEnvIf on this forum so posting my query here as well.

~G1
alias Jeevan

jdMorgan

8:49 pm on Feb 17, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The answer depends on whether your jBoss requests are currently Aliased or proxied to your back-end. If so, then you will need to check to be sure that mod_setenvif executes before mod_alias and mod_proxy.

On Apache 1.x, the modules are executed in the *reverse* order that they are added (using AddModule). On Apache 2.x, the modules are executed according to some internal priority scheme, and if the order is incorrect, I'm not sure you can do anything about it. So check this.

You may also want to look into using mod_rewrite, with the [P] flag on a RewriteRule to implement your balanced reverse-proxy function. The IP addresses can be tested using a RewriteCond testing %{REMOTE_ADDR}.

This assumes that there is no jBoss "session" associated with these requests to be balanced. If there is any persistent session, then you will likely want to always proxy the same user to the same back-end server during a session.

Because some users may switch IP addresses from request to request (for example all AOL users), you may need two levels of logic: Set an IP-address-based browser-session cookie if no such cookie has already been set. Then do the load-balancing based on that cookie. This ensures that during each browser session, the user is always sent to the same back-end server. When the user closes his browser, the browser-session cookie will be deleted. Since a jBoss-server-session will occur entirely within the same browser session, this simple approach is good enough.

Jim

jnsunkersett

5:19 pm on Feb 19, 2011 (gmt 0)

10+ Year Member



Thank you Jim.

Request a couple of clarifications...
>>> The answer depends on whether your jBoss requests are currently Aliased or proxied to your back-end.
>>>>If so, then you will need to check to be sure that mod_setenvif executes before mod_alias and mod_proxy.

I do not know if it is either of them, how can I find out (I have followed the article on mod_jk)

>> You may also want to look into using mod_rewrite

Are you suggesting that I try mod_rewrite (instead of mod_jk)?

Please can you point me to an article explaining how-to?

thanks again
~G1
alias Jeevan