load balancing in apache on jira cluster - apache

Please help me in configuration my httpd.
I made all what write in off site jira : https://developer.atlassian.com/jiradev/jira-architecture/jira-data-center/plugin-guide-to-jira-high-availability-and-clustering/configuring-a-jira-cluster-for-plugin-development
But if I go to link I got the simple test page of Apache. But why?
I'm not understand why balancing is not working.
my httpd.conf (part):
< VirtualHost *:80>
ProxyRequests off
ServerName jira-cluster.com
<Proxy balancer://jiracluster>
BalancerMember http://jira1.com:8080 route=node1
BalancerMember http://jira2.com:8080 route=node2
Order Deny,Allow
Deny from none
Allow from all
ProxySet lbmethod=byrequests
ProxySet stickysession=JSESSIONID
</Proxy>
<Location /balancer-manager>
SetHandler balancer-manager
Order deny,allow
Allow from all
</Location>
ProxyPass /balancer-manager !
ProxyPass / balancer://jiracluster/
ProxyPreserveHost on
< /VirtualHost>

Have you tried swapping * for your domain name
e.g. < VirtualHost mydomain.com:80>

Related

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>

Force URL pattern to specific balancer member in apache

I have a load balancer in apache with currently only two members. I want the URL's starting with "admin" to be mapped to a specific instance (http://localhost:16666/) because the admin site needs access to files on the CDN which is also in this machine. I could handle this by mounting this folder to the other server, or implementing a separate service doing this, but that's the last thing I want now. I was about to create a new proxypass rule to map these to this member rather than the balancer, but it simply ignores it.
The important part of my vhost config:
<Location /balancer-manager>
SetHandler balancer-manager
</Location>
<Proxy balancer://videoportal>
BalancerMember http://localhost:16666
BalancerMember http://example.com:16666
Require all granted
ProxySet lbmethod=byrequests
</Proxy>
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ErrorLog /var/log/apache2/videoportal-error.log
ProxyPass /balancer-manager !
ProxyPass "/admin" "http://localhost:16666/admin"
ProxyPassReverse "/admin" "http://localhost:16666/admin"
ProxyPass / balancer://videoportal/
ProxyPassReverse / balancer://videoportal/
ProxyRequests Off
Any advice what am I doing wrong?
First you are mixing apache 2.2 and apache 2.4 config
In apache 2.2 use
Order deny,allow
Allow from all
//Your apache config//
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
In apache 2.4
Require all granted
//Your apache config//
<Proxy balancer://videoportal>
...
Require all granted
ProxySet lbmethod=byrequests
</Proxy>
Second try put the /admin before the balancer definition
...
SetHandler balancer-manager
</Location>
ProxyPass "/admin" "http://localhost:16666/admin"
ProxyPassReverse "/admin" "http://localhost:16666/admin"
<Proxy balancer://videoportal>
BalancerMember http://localhost:16666
...
I figured out what was the problem.
I created a location rule for this and added a header to track if it's working:
<Location /balancer-manager>
SetHandler balancer-manager
</Location>
<Proxy balancer://videoportal>
BalancerMember http://localhost:16666
BalancerMember http://example.com:16666
Require all granted
ProxySet lbmethod=byrequests
</Proxy>
<Proxy *>
Require all granted
</Proxy>
ErrorLog /var/log/apache2/videoportal-error.log
ProxyPass /balancer-manager !
# This is the new part
<Location "/admin">
ProxyPass "http://localhost:16666/admin"
ProxyPassReverse "http://localhost:16666/admin"
Header set ADMIN "true"
</Location>
# end of new part
ProxyPass / balancer://videoportal/
ProxyPassReverse / balancer://videoportal/
ProxyRequests Off

Configuring Apache Load Balancer

I have the following code added to my httpd.conf to load balance between two Application Servers
<VirtualHost www.mydomainx.com:80>
ProxyRequests off
ProxyPreserveHost Off
ServerName www.mydomainx.com
ServerAlias mydomainx.com
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /test balancer://mycluster stickysession=JSESSIONID|jsessionid
<Proxy balancer://mycluster>
# WebHead1
BalancerMember http://www1.mydomainx.com
# WebHead2
BalancerMember http://www2.mydomainx.com
Order Deny,Allow
Deny from none
Allow from all
ProxySet lbmethod=byrequests
</Proxy>
<Location /balancer-manager>
SetHandler balancer-manager
# I recommend locking this one down to your
# your office
Order deny,allow
Allow from all
</Location>
ProxyPass /balancer-manager !
ProxyPass / balancer://mycluster/
</VirtualHost>
Whenever i enter the URL to a web browser www.mydomainx.com, it loads the home page , then if i enter a user name and password and click submit, it then reloads either (http://www1.mydomainx.com / http://www2.mydomainx.com) reloading the home page again and forcing me to re-enter the username and password, is there a way to prevent all this?
Make sure you follow the advice in section stickyness:
ProxyPass / balancer://mycluster stickysession=JSESSIONID|jsessionid scolonpathdelim=On
(not only for the /test directory)
Furthermore, for the JBoss application server, you need to supply route=web1 / route=web2 etc. in the Apache config and furthermore jvmRoute="web1" in the JBoss configuration of the <Engine name="jboss.web"... element (the location depends on the JBoss version you are using, for v4.2 it is server/default/deploy/jboss-web.deployer/server.xml)
See also this tutorial

Apache load balancing with tomcat : losing session

I am using proxy pass to load balance my workers. Somehow my tomcat session is getting lost and recreated. I tried standalone tomcat and it works fine but not with load balancer. Please help.
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /balancer-manager !
ProxyPass /images !
ProxyPass / balancer://mycluster/
ProxyPassReverse / balancer://mycluster/
<Proxy balancer://mycluster>
BalancerMember ajp://192.168.70.6:9061 route=qa1
ProxySet lbmethod=byrequests
</Proxy>
<Location /balancer-manager>
SetHandler balancer-manager
</Location>
<Directory "/Library/WebServer/Documents">
AllowOverride all
</Directory>
I finally figured out the cause of the issue. I had another server which was being invoked by an absolute URL from the site which was causing the workers JSESSIONID to be overwritten.