Configuring Apache Load Balancer - apache

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

Related

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

Load balancer with apache httpd and wildfly for rest web services with mod_proxy

I have an apache load balancer with mod_proxy and wildfly (apache 224 and wildfly 9).
I have 4 servers in domain in wildfly and the load balancer works fine with a "hello world" app, and in the balancer manager i can see how the requests are sent to each server.
The thing is, When I use the app that has some REST web services, i am sending the request with a GET method and some headers for authentication, and somehow, the application is responding with error when i access it through the load balancer, but if I send it directly to the server, it works correctly.
my cofiguration goes as follows
<VirtualHost *:80>
ProxyRequests Off
<Proxy balancer://mycluster>
BalancerMember http://localhost:8080/ loadfactor=25
BalancerMember http://localhost:8230/ loadfactor=25
BalancerMember http://localhost:8330/ loadfactor=25
BalancerMember http://localhost:8430/ loadfactor=25
</Proxy>
<Location /balancer-manager>
SetHandler balancer-manager
Order Deny,Allow
Allow from all
</Location>
<Location /test>
Order allow,deny
Allow from all
</Location>
ProxyPass /test balancer://mycluster stickysession=JSESSIONID
I am testing using postman and sending the requests with a get method and a header for authentication: basic {base64 code} as follows:
http://127.0.0.1/test/myproject.ws/myproject/get_list?key=T11108101191&page=1
and this results in error.
when i try this:
http://127.0.0.1:8080/myproject.ws/myproject/get_list?key=T11108101191&page=1
This goes ok
and when i try the above, but with a post method, it gets the same error as in the load balancer.
Any idea of what am i doing wrong?
PS: I've tried putting in the WEB-INF/web.xml of the project, but i still get the same error.
Thanks to Dusan Bajic, he saw the problem I had. In the balancer member i was finishing the route with "/" and when I used the ProxyPass, i was starting with "/", duplicating that character. Somehow, with the helloworld app it worked correctly, but when i pass parameters, it failed.
The new configuration goes as follows:
<VirtualHost *:80>
ProxyRequests Off
<Proxy balancer://mycluster>
BalancerMember http://localhost:8080 loadfactor=25
BalancerMember http://localhost:8230 loadfactor=25
BalancerMember http://localhost:8330 loadfactor=25
BalancerMember http://localhost:8430 loadfactor=25
</Proxy>
<Location /balancer-manager>
SetHandler balancer-manager
Order Deny,Allow
Allow from all
</Location>
<Location /test>
Order allow,deny
Allow from all
</Location>
ProxyPass /test balancer://mycluster stickysession=JSESSIONID
</VirtualHost>

load balancing in apache on jira cluster

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>

Can we allow unsecure websocket(ws://) over https protocol?

I have already tried using ws:// over https in firefox using some flag configuration. Is there any way to enable this configuration in IE 10 . May be by adding some reg entry it can be done but i don't know exactly which key vale to edit?
I have configured my https using apache httpd service. Which routes to my play portal URL. Is there any setting/config extra i am missing. Here is my httpd configuration:
<VirtualHost *:80>
ServerName myhost
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
SSLEngine on
SSLProxyEngine On
SSLCertificateFile /etc/ssl/certs/my.crt
SSLCertificateKeyFile /etc/ssl/private/my.key
ProxyRequests on
ProxyPreserveHost off
<Location />
SetHandler balancer-manager
Order allow,deny
Allow from all
</Location>
#ProxyPass /excluded !
ProxyPass / http://host-to-route:9701/
ProxyPassReverse / http://host-to-route:9701/
</VirtualHost>
Please suggest.
Thanks,
Sohan

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.