Which load balancer supports Master/Slave configuration? - apache

I am looking for load balancer for my web application that will support master-slave kind of configuration or algorithm support.
For now I am using apache proxy but with round robin LB method.
I am not sure if apache load balancer has master-slave support or any module?
Here is what I want exactly: Forward all request to one back end server and once the master server is down the slave or other server will act as hot stub.
Please suggest if any open source load balancer I can use w.r.t to my above requirement.

You can use nginx with its Upstream module.
Example configuration:
upstream myBackend {
server main.example.com:8080;
server back.example.com:8080 backup;
}
server {
location / {
proxy_pass http://myBackend;
}
}
While the first server (main.example.com) is up, nginx will use it. When it comes down, it will use the second server. You can read in the linked manual page for various other tuning parameters (for example when to mark server as failed). Nginx supports HTTPS for both incoming connections and also for connections to the proxy backend.
EDIT: For Apache it seems to be possible in version 2.4 using the Proxy Balancer. I have not tested this config. For more details see manual for ProxyPass.
ProxyPass "/" "balancer://hotcluster/"
<Proxy "balancer://hotcluster">
BalancerMember "http://1.2.3.4:8000"
# The server below is on hot standby
BalancerMember "http://1.2.3.6:8000" status=+H
</Proxy>

Related

websphere and apache server proxy and rewrite configuration

There are javaEE applications run on WebSphere server.
The thing I wanna do that to configure a http server that takes the request and redirect to my local websphere server.
For example:
This is live Project testProject.com/Otel..
I wanna reach my local project when I insert local.testProject.com/Otel..
The thing I have done so far I can reach my local apache server when I click local.testProject.com just with adding in host file in windows/system32/drivre/etc directory.
The thing I could not do so far. redirecting this incoming request to my apache server to websphere server.
Could you please help me on these. Dont hasitate to ask further questions.
I would be appreciated if you could give me some ideas with just commenting at least.
Good days..
IBM provides a specialty reverse proxy module for Apache called the WebSphere WebServer Plug-in. Its use is described in detail in the websphere documentation.
In simple configurations, you can just configure any server you already have as a reverse proxy.
Load mod_proxy and mod_proxy_http (varies depending on Apache distribution)
Append to your virtual host:
ProxyPreserveHost ON
ProxyPass /otel http://washostname.example.com/otel
# ProxyPassReverse likely not required in your case.
Of course there are thousands of places to read about setting up Apache as a reverse proxy and there are nearly no WebSphere specifics.

tomcat cluster apache in front - How to load balance?

What apache module would fit better to build the following cluster:
2x Red Hat each has a tomcat an apache.
No Scalability needs.
High availability needs.
Session replication needs.
DNS
|
Load Balancer
/ \
APACHE1 APACHE2
TOMCAT1 TOMCAT2
The question is regarding what module to use for the load balancing with apache?
mod_proxy
mod_cluster
other?
If I understand mod_cluster correctly, it must be used with JBoss, or with a modified Tomcat. So if you are using plain-old Tomcat (or TomEE), then I think mod_cluster is out.
The easiest out-of-the box option is to use mod_proxy with either the AJP or HTTP back-end. If you are comfortable building additional modules, mod_jk is available from the Tomcat folks and offers a few advantages over mod_proxy, though mod_proxy has nearly achieved feature-parity.
Your diagram suggests that a load-balancer will be choosing between two httpd instances which are coupled directly to a single Tomcat instance each. In that scenario, httpd is not performing any load-balancing at all (the lb is doing the work), and so httpd might be superfluous in that configuration.
If you instead want to cross-link both httpds with both Tomcats, that's when you start having to configure cluster-like behavior with mod_proxy's "balancer" configurations. It would look something like this:
<Proxy balancer://appA>
BalancerMember http://tomcatA:8080/appA
BalancerMember http://tomcatB:8380/appA
</Proxy>
ProxyPass /appA balancer://appA
ProxyPassReverse /appA balancer://appA
There are tons of options for mod_proxy that you should read about and apply to suit your configuration. You can configure things like sticky-sessions, hot-standbys (not present in your example diagram but a good idea if you really need HA), and asymmetric load-balancing.

Nginx (SSL) -> Varnish -> Apache upstream load balancing/ failsafe

I want to setup the following infratructure: Nginx as ssl terminator/ load balancer in front of a Varnish cache which itself uses Apache backends.
Now I want to load balance the traffic in the following way. Primary backend should be the Varnish backend. Backup backend should be the Apache backend directly. And another backup backend, that simply shows a maintenance page, if the Varnish backend and the Apache backend is down.
I have tested the proxy_pass upstream the following ways:
upstream backends {
server VARNISH-HOST;
server APACHE-HOST backup;
server MAINTENANCE-HOST backup;
}
With this setup, and Varnish offline, the system cycles throuhg both backends with round-robin - not first backup and, if offline too, second backup.
Another configuration:
upstream backends {
server VARNISH-HOST weight=10;
server APACHE-HOST;
server MAINTENANCE-HOST backup;
}
But I am not sure if this is the right way?! What is the best/ right way to setup the upstream backends in the way I want them to respond? Any advice?
Regards.

Configuration of Apache and Tomcat for load balancing

I'm trying to setup Apache as a load balancer for 2 Tomcat instances with session affinity.
The goal is to have the session stick to one server but to have next session (when it's changed by the backend server) to go to the next available server (let's say using round-robin algorithm for easier implementation). When using the "jvmRoute" in Tomcat and an equivalent "route" in Apache the actual value that does the routing is the route name which does not change and all requests are routed always to the same backend server for a single client.
I found out so far that there's an chicken/egg problem when using just the JSESSIONID cookie. Let's consider the following setup:
2 Tomcat servers listening on ports 8009 and 8010 (AJP13)
1 Apache server with the following configuration
<Proxy balancer://hello-cluster>
BalancerMember ajp://127.0.0.1:8009/hello
BalancerMember ajp://127.0.0.1:8010/hello
</Proxy>
ProxyPass /hello balancer://hello-cluster stickysession=JSESSIONID
And here's the scenario:
The first request has no cookie so Apache selects the next available server in the load balancer to handle the request.
The backend Tomcat server sets JSESSIONID but does not note the actual value being returned.
The next request comes in, Apache notes that there's no backend server noted for the given JSESSIONID so it selects the next available, which in this case the other one as served the first request
Tomcat notices that the value of JSESSIONID is invalid so it creates a new one.
Apache does not take a note that the JSESSIONID has changed to pin it down to that backend server.
Back to pt. 3
Is there a way to convince Apache to note the value returned by Tomcat?
maybe if you try with tomcat session replication. I found this interesting post:
http://www.bradchen.com/blog/2012/12/tomcat-auto-failover-using-apache-memcached
.
You could try too with redis:
http://shivganesh.com/2013/08/15/setup-redis-session-store-apache-tomcat-7/
Let me know your experience please.

How to setup a forward proxy and a reverse proxy on the same server using Apache HTTPD

I have an application that acts as both a HTTP server as well as a HTTP client. For security reasons, the application runs on a server on a protected/internal network. I would like to setup a HTTP proxy that acts as an external interface for external parties to access the application.
For external HTTP clients to access my application, I would like to have a reverse proxy to handle such scenarios.
For HTTP request from my application to external parties, I would like to have a forward proxy to ensure my proper external URL's are sent to the external parties.
Question: Can Apache HTTPD proxy be configured to run a both a forward proxy and reverse proxy at the same time?
The short answer (from my reading of the docs) is No.
The forward proxy is activated using the ProxyRequests directive
A reverse proxy is activated using the ProxyPass directive.
The reverse proxy docs state
The ProxyRequests directive should
usually be set off when using
ProxyPass.
I think if you enable both on the same server, there will be a possible clash in your Allow, Deny settings for IPs etc