apache mod_proxy cluster with websockets and http - apache

I have
apache 2.4.10 192.168.0.10
jboss8 node1 192.168.0.20 - in domain mode
jboss8 node2 192.168.0.21 - in slave mode -
I trying create cluster via mod_proxy http://192.168.0.10/myapp with http and websocket connections
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot /var/www/html/cluster1
ServerName 192.168.0.10
ErrorLog logs/cluster1_log_error
CustomLog logs/cluster1_log_comm common
TransferLog logs/cluster1_log_trans
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
<Proxy balancer://jboss>
BalancerMember ws://192.168.0.21:8080 route=2
BalancerMember http://192.168.0.21:8080 route=2
BalancerMember ws://192.168.0.20:8080 route=1
BalancerMember http://192.168.0.20:8080 route=1
ProxySet stickysession=ROUTEID
ProxySet nofailover=off
</Proxy>
ProxyPreserveHost On
ProxyRequests Off
ProxyPass /myapp balancer://jboss/myapp
ProxyPassReverse /myapp balancer://jboss/myapp
<Location /mcm>
SetHandler balancer-manager
</Location>
but If I disable workers ws and http for jboss2 via balancer manager -
traffic still sending to node
how to do it right ?
two balancers ?
one balancer ?
I need help

Related

Apache 2.4 configuration for etag in proxy

For Apache 2.4, how do you remove inode information from the ETag header? It looks like you normally do that by adding the following directive to your Apache config:
FileETag MTime Size
Where do you put Entity Tag configuration when your vhost is mostly just a proxy? Here is a basic example:
<VirtualHost web-cname.internaldomain.com>
ServerName web-arec.internaldomain.com
ServerAlias www.example.com
SSLEngine On
ErrorLog base_dir/example_error_log
CustomLog base_dir/access_log custom
SSLProxyEngine On
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Proxy balancer://myset>
BalancerMember https://app1-arec.internaldomain.com:8080
BalancerMember https://app2-arec.internaldomain.com:8080
</Proxy>
ProxyPass /abc/ balancer://myset/abc/
ProxyPass /def/ balancer://myset/def/
</VirtualHost>
Where do I put the etag directive?

Apache load balancer just uses first entry

I have configured a loadbalancer for Apache as following:
<Proxy "balancer://mycluster">
BalancerMember "http://127.0.0.1:8081/" loadfactor=1
BalancerMember "http://127.0.0.1:8082/" loadfactor=1
ProxySet lbmethod=byrequests
</Proxy>
<VirtualHost *:80>
ServerName subdomain.example.com
ProxyPass / "balancer://mycluster"
ProxyPassReverse / "balancer://mycluster"
</VirtualHost>
If i fire some requests at it like in
for i in `seq 1 100`
curl http://subdomain.example.com/ping &
I get my pong (which is the balancers response) 100 times
But the logs are only showing the requests in my first BalancerMember at port 8081.
How can I debug this or change to a round-robin style?

configuring multiple domains using virtual host with mod proxy in a single httpd instance

I have an apache instance running three domains using name based virtual hosting and every domain has resources to reverse proxy them down to an application server. Application server is a JBoss running a since JVM instance (http://x.x.x.x:8080/)
The domains along with their resources are,
www.abc.com
- alpha
www.def.com
- beta
www.ghi.com
- gamma
- (root URL - no resource)
abd.com and def.com domains have one resource whereas ghi.com has two (root (/) and gamma).
this is how we have setup virtual hosting for three different domains. A sample for abc.com domain is below,
<VirtualHost *>
ServerName abc.com
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/alpha" env=BALANCER_ROUTE_CHANGED
<Proxy balancer://mycluster1>
<LimitExcept POST GET>
order Allow,Deny
Deny from all
</LimitExcept>
BalancerMember http://x.x.x.x:8080 route=1 retry=0
BalancerMember http://x.x.x.x:8081 route=2 retry=0
ProxySet stickysession=ROUTEID
</Proxy>
ProxyPass /alpha balancer://mycluster4/alpha
ProxyPassReverse /alpha balancer://mycluster4/alpha
</VirtualHost>
With all configuration in place when I try accessing these domains,
www.abc.com/alpha --> works
www.def.com/beta --> works
www.ghi.com/gamma --> works
www.ghi.com/ --> works
since ghi.com domain has a root mapping (/) I am able to access resources of other domain through ghi.com and if I remove the root mapping, cross domain resource accessibility does not work.
www.ghi.com/alpha --> works
www.ghi.com/beta --> works
I do not want the resources of other domain to be accessed through ghi.com. I cannot remove root mapping from ghi.com virtual host configuration.
We have tried multiple configuration but none has worked out.
I may sound bit non technical here which I apologize, but this is my problem statement and I am looking for for a fix.
update 1: configuration file after fix proposed by pandurang.
NameVirtualHost *
<VirtualHost *>
ServerName ghi.com
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/gamma " env=BALANCER_ROUTE_CHANGED
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/ " env=BALANCER_ROUTE_CHANGED
<Proxy balancer://mycluster4>
<LimitExcept POST GET>
order Allow,Deny
Deny from all
</LimitExcept>
BalancerMember http://x.x.x.x:8080 route=1 retry=0
BalancerMember http://x.x.x.x:8081 route=2 retry=0
ProxySet stickysession=ROUTEID
</Proxy>
ProxyPass /gamma balancer://mycluster4/gamma
ProxyPassReverse /gamma balancer://mycluster4/gamma
ProxyPass / balancer://mycluster4/
ProxyPassReverse / balancer://mycluster4/
ProxyPass /alpha !
</VirtualHost>
Use the below sequence and test.
ProxyPass /alpha !
ProxyPass /gamma balancer://mycluster4/gamma
ProxyPassReverse /gamma balancer://mycluster4/gamma
ProxyPass / balancer://mycluster4/
ProxyPassReverse / balancer://mycluster4/
Create Three different Name-based VirtualHost and disable context(alpha and beta) in www.ghi.com.
<VirtualHost www.abc.com>
ServerName abc.com
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/alpha" env=BALANCER_ROUTE_CHANGED
<Proxy balancer://mycluster1>
<LimitExcept POST GET>
order Allow,Deny
Deny from all
</LimitExcept>
BalancerMember http://x.x.x.x:8080 route=1 retry=0
BalancerMember http://x.x.x.x:8081 route=2 retry=0
ProxySet stickysession=ROUTEID
</Proxy>
ProxyPass /alpha balancer://mycluster4/alpha
ProxyPassReverse /alpha balancer://mycluster4/alpha
</VirtualHost>
<VirtualHost www.def.com>
ServerName def.com
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/beta" env=BALANCER_ROUTE_CHANGED
<Proxy balancer://mycluster1>
<LimitExcept POST GET>
order Allow,Deny
Deny from all
</LimitExcept>
BalancerMember http://x.x.x.x:8080 route=1 retry=0
BalancerMember http://x.x.x.x:8081 route=2 retry=0
ProxySet stickysession=ROUTEID
</Proxy>
ProxyPass /beta balancer://mycluster4/beta
ProxyPassReverse /beta balancer://mycluster4/beta
</VirtualHost>
<VirtualHost www.ghi.com>
ServerName ghi.com
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
<Proxy balancer://mycluster1>
<LimitExcept POST GET>
order Allow,Deny
Deny from all
</LimitExcept>
BalancerMember http://x.x.x.x:8080 route=1 retry=0
BalancerMember http://x.x.x.x:8081 route=2 retry=0
ProxySet stickysession=ROUTEID
</Proxy>
ProxyPass /alpha !
ProxyPass /beta !
ProxyPass / balancer://mycluster4/
ProxyPassReverse / balancer://mycluster4/
</VirtualHost>

Apache Load Balancing

Hello im new on Apache Server i try to do a load balance over my local machine with multiple page on different folder load1,load2 i try to do a configuration according to the documentation but i cant see the effect here is my config
<VirtualHost *:1000>
ProxyRequests Off
ProxyTimeout 300
ProxyPreserveHost On
ProxyVia On
ErrorLog "logs/yoni-error.log"
CustomLog "logs/yoni-access.log" common
<Proxy balancer://mycluster>
BalancerMember http://yoni.com:1000
BalancerMember http://yoni1.com:1000
ProxySet lbmethod=byrequests
</Proxy>
ProxyPass /load balancer://mycluster/
ProxyPassReverse /load balancer://mycluster/
<Location /balancer-manager>
SetHandler balancer-manager
</Location>
</VirtualHost>

Apache 2.4 - configure ProxyPass based on full url instead of trailing path

Currently I have the following ProxyPass's configured in my Apache httpd.conf file.
The goal is to have one Proxypass on http://myurl.com:port1/mypath to one balance group, and then have any additional Proxypass go to http://myurl.com:port2/mypath to any additional balance groups.
Here is my code currently as is which only works based on the /mypath apparently and can have no proceeding URL. The problem is my two /mypath's are the same and only differ by port1 and port2 in the URL.
I am currently listening on Port1 and Port2 defined above in Apache, but I have no way currently to distinguish if someone who comes in on myurl.com:port1 will get directed to Group1 or Group2 in the balance manager because the /mypath is the same for both.
<IfModule proxy_module>
ProxyPass /mypath balancer://Group1/ stickysession=JSESSIONID|jsessionid
ProxyPass /mypath balancer://Group2/ stickysession=JSESSIONID|jsessionid
<Proxy balancer://Group1>
BalancerMember ajp://myurl.com:portX/mypath route=TC01
</Proxy>
<Proxy balancer://Group2>
BalancerMember ajp://myurl.com:portY/mypath route=TC01
</Proxy>
</IfModule>
The below does not work but this is essentially what I am trying to do:
<IfModule proxy_module>
ProxyPass http://myurl.com:port1/mypath balancer://Group1/ stickysession=JSESSIONID|jsessionid
ProxyPass http://myurl.com:port2/mypath balancer://Group2/ stickysession=JSESSIONID|jsessionid
<Proxy balancer://Group1>
BalancerMember ajp://myurl.com:portX/mypath route=TC01
</Proxy>
<Proxy balancer://Group2>
BalancerMember ajp://myurl.com:portY/mypath route=TC01
</Proxy>
</IfModule>
Since ProxyPass cannot occur within <If> section, seems like you are left with splitting your configuration in two VirtualHosts:
<VirtualHost *:port1>
ServerName myurl.com
<Proxy balancer://Group1>
BalancerMember ajp://myurl.com:portX/mypath route=TC01
</Proxy>
ProxyPass /mypath balancer://Group1/ stickysession=JSESSIONID|jsessionid
</VirtualHost>
<VirtualHost *:port2>
ServerName myurl.com
<Proxy balancer://Group2>
BalancerMember ajp://myurl.com:portY/mypath route=TC01
</Proxy>
ProxyPass /mypath balancer://Group2/ stickysession=JSESSIONID|jsessionid
</VirtualHost>