httpd: stickysession and nofailover - apache

i have config file contains:
<VirtualHost _default_:80>
RewriteEngine On
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto "https" env=HTTPS
<Proxy "balancer://webtop">
BalancerMember "http://internalsite:7003" route=web1 ping=2
BalancerMember "http://internalsite:7006" route=web2 ping=2
ProxySet lbmethod=byrequests
</Proxy>
<Location /webtop>
ProxyPass balancer://webtop/webtop stickysession=ROUTEID nofailover=On
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/webtop" env=BALANCER_ROUTE_CHANGED
</Location>2
</VirtualHost>
Questions:
First connect. We have no routeid cookie. Could balancer check BalancerMember status before first assigning to prevent assign to inactive BalanceMember?
Something happens. We have routeid cookie, for example, web1, but this BalancerMember is down. We make new request. Could httpd automaticaly change cookie to web2 and switch to this BalanceMember?
i'm trying to config apache httpd as balancer

First connect. We have no routeid cookie. Could balancer check BalancerMember status before first assigning to prevent assign to inactive BalanceMember?
The cookie can either be set by the backend.You can set cookies at ProxyPass or ProxySet. The balancer extracts the value of the cookie and looks for a member worker with a route equal to that value.
Something happens. We have routeid cookie, for example, web1, but this BalancerMember is down. We make new request. Could httpd automatically change cookie to web2 and switch to this BalanceMember?
Yes. If nofailover is set to On, the session will break if the worker is in an error state or disabled. Set this value to On if backend servers do not support session replication.

Related

path based routing on apache

I have regular load balancing working in Apache. I want to change that to use path based routing and load balancing
I am looking for some guidance on path based routing in Apache
Currently I have 3 servers running Apache.
I have load balancer, which has configuration as follows
What I want to change this is path based routing /load balancing
For ex: if someone types url/app , it should automatically be redirected app server on port 3000
if someone types url/rpt , it should automatically be redirected 3230
if someone types url/azn , it shoudl be redirected to 4010
<Proxy balancer://app0108>
#BalancerMember https://app01.us.ray.com route=1
BalancerMember https://p.q.r.s route=1
#BalancerMember https://app02.us.ray.com route=2
BalancerMember https://a.b.c.d route=2
#BalancerMember https://app03.us.ray.com route=3
BalancerMember https://x.y.a.sd route=3
ProxySet stickysession=ROUTEID
ProxyPass / "balancer://app0108/" failonstatus=503 maxattempts=10 timeout=2400
ProxyPassReverse / "balancer://app0108"
ProxyStatus On
ServerName xxxxx:443
ServerAlias xxxxxx
ErrorLog logs/alb.errors.log
thanks

how to configure http uri healthcheck for a ws balancer with Apache Httpd

i need to configure healthcheck for my ws load balancer within Apache httpd.
i am using mod_proxy_wstunnel for websocket tunneling and mod_balancer for load balancing between 2 servers.
i am using additionnaly mod_proxy_hcheck for verifying if the 2 servers are available.
the configuration is following:
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
ProxyHCExpr ok2 {%{REQUEST_STATUS} =~ /^[2]/}
<Proxy balancer://trackingwsbalancer>
BalancerMember wss://{{ rpa_fqdn_tracking1 }}:8443 route=1 hcmethod=GET hcexpr=ok2 hcuri=/trackingproxy_advanced/actuator
BalancerMember wss://{{ rpa_fqdn_tracking2 }}:8443 route=2 hcmethod=GET hcexpr=ok2 hcuri=/trackingproxy_advanced/actuator
ProxySet stickysession=ROUTEID
ProxySet lbmethod=bybusyness
</Proxy>
the problem is that the healthcheck always fails because the request behind is:
wss ://{{ rpa_fqdn_tracking1 }}:8443/trackingproxy_advanced/actuator.
and i want it to be
htpps ://{{ rpa_fqdn_tracking1 }}:8443/trackingproxy_advanced/actuator
in order to be able to handle the response for healthcheck correctly with hcexpr
i will greatly appreciate any idea to configure the protocole for the uri healthcheck.
The documentation of the mod_proxy_hcheck module says that it performs a HTTP request.
After inspecting the mod_proxy_hcheck.c( Apche 2.4.39), it seems that this case is not covered. The code doesn't check if the scheme is ws and does not replace it when it create the request.
It should be great to be able to add an absolute uri for the hckeck or replace automatically the protocol used if it's not http.

Load balancing between servers using Apache and JBoss

I am facing the following scenario: I have three servers, each with an instance of my application deployed in a standalone JBoss, I am trying to use a machine that will do the load balancing service between these three servers, for this I am using the module mod_proxy_balancer from Apache (or at least trying), and it was even easy to do the balancing, it worked correctly, however I am having problems in keeping users session and cookies, because whenever a new request is made, the balancer sends it to another server, causing that the user loses his session, I would like that when a user already had a session in one of the servers the same one was sent to him, or something of the type.
Is it possible to achieve the desired result using such resources? If so, how should I make such a setup? If not, what other tool or feature should I use?
Here's the virtual host configuration:
<VirtualHost *:80>
ServerName server.int
ProxyPass / balancer://balance/ stickysession=JSESSIONID|jsessionid scolonpathdelim=On
ProxyPass /balancer-manager !
ProxyPassReverse / balancer://balance/ stickysession=JSESSIONID|jsessionid scolonpathdelim=On
ProxyPassReverseCookiePath / /
<Proxy balancer://balance/>
BalancerMember "http://server1.int" loadfactor=50
BalancerMember "http://server2.int" loadfactor=25
BalancerMember "http://server3.int" loadfactor=25
ProxySet lbmethod=byrequests
</Proxy>
<Location /balancer-manager>
SetHandler balancer-manager
</Location>
</VirtualHost>
Although no one has answered, I will leave here the solution to my problem if this helps anyone in the future. I ended up using HAProxy that can do exactly what I needed in a very simple way.
frontend app
bind *:80
bind *:443 ssl crt /etc/haproxy/certs/cert.pem
redirect scheme https if !{ ssl_fc }
mode http
default_backend app
backend app
balance leastconn
mode http
option httpchk HEAD / HTTP/1.0
cookie SERVERID insert indirect nocache
server server1 server1.test.com:80 check weight 50 fall 3 rise 2 cookie server1
server server2 server2.test.com:80 check weight 50 fall 3 rise 2 cookie server2
server server3 server3.test.com:80 check weight 50 fall 3 rise 2 cookie server3

Endeca cluster load balancing

I have an Endeca cluster setup with 3 dgraph(1 EAC Central Server and 2 EAC agent only instances). I am trying to put an Apache mod_proxy load balancer for testing purpose before the MDEX engines(I am using presentation API to hit the MDEX engine(we are working on assembler API also)). We shall be having an F5(or Nginx, which one shall be better?) hardware load balancer when we'll shall do the actual deployment. My apache server is listening at port 5555, All my Dgraphs are running at port 15000 on three different host. I'm directing the all my queries to apache load balancer.
MDEX_HOST = localhost
MDEX_PORT = 5555
private static ENEConnection createConnection() {...}
And here is my Apache Load balancer configuration. Load balancer modules included in httpd.conf file mod_proxy, mod_proxy_balancer, mod_proxy_connect, mod_proxy_http, mod_negotiation. I have put the load balancer configuration in httpd-vhosts.conf file.
NameVirtualHost *:5555
<VirtualHost *:5555>
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/"
env=BALANCER_ROUTE_CHANGED
ServerName localhost
ProxyPass / balancer://cluster/
<Proxy balancer://cluster>
BalancerMember http://172.16.26.129:15000 loadfactor=1 retry=0 route=1
BalancerMember http://172.16.26.210:15000 loadfactor=1 retry=0 route=2
BalancerMember http://172.16.27.87:15000 loadfactor=1 retry=0 route=3
Order Deny,Allow
Deny from none
Allow from all
ProxySet lbmethod=byrequests
ProxySet stickysession=ROUTEID
</Proxy>
</VirtualHost>
<Location /balancer-manager>
SetHandler balancer
</Location>
When I do a query(Type ahead service) I'm getting the following error..
** Error Fri Apr 10 20:05:53 IST 2015 1428676553858 /atg/rest/processor/RestActorManager Caused by (#6):com.endeca.navigation.ENEException: HTTP Error 404 - Navigation Engine not able to process request 'http://localhost:5555/search?terms=je&rank=0&offset=0&irversion=640'.
Can anyone please see my load balancer configuration what I'm doing wrong? Thanks

mod_ajp_proxy configurations and session stickiness

All,
I have a jboss and apache setup hosting my .war file. I have enabled session stickiness to forward requests from apache to jboss . Assume i have 2 apache and 2 jboss instances.
Is the below setting correct ? Currently session stickyness is not working and each time request is appended with a new JSESSSION ID.
<Proxy balancer://cluster>
Order deny,allow
Allow from all
BalancerMember ajp://1.1.1.1:8010/testing keepalive=On loadfactor=1 ping=10 ttl=600
BalancerMember ajp://2.2.2.2:8010/testing keepalive=On loadfactor=1 ping=10 ttl=600
</Proxy>
ProxyPass /testing balancer://cluster timeout=60 stickysession=JSESSIONID nofailover=On
Do i need to add route variable to the balancer member configuration ??? and do i need to enable useJK flag in jboss.
YES, you need to add route to each balancer member.
route=member1
route=member2
That is how Apache knows which way to direct later requests. Look at your cookies in your browser.