Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Apache to work as proxy (load balancer) for j2ee server?

I have apache web server installed as frontend and I have j2ee SAP Netweaver Application Server installed in Intranet server. How can I configure apache to forward requests and response to/from j2ee app server. for example, external apache server's ip is 9.20.1.1:80. internal sap server's address is 192.168.0.1/sap/bc/gui/sap/its/webgui?sap_client=200 I want access to my sap app server for example 9.20.1.1/sapserver/sap/bc/gui/sap/its/webgui?sap_client=200

like image 653
Vik Gamov Avatar asked Oct 13 '08 18:10

Vik Gamov


People also ask

Can Apache be used as load balancer?

Apache load balancer is open source and provides a server application traffic distribution solution. According to recent statistics, it has been utilized in over 100,000 websites.

What is Apache HTTP proxy?

Apache HTTP Proxy is a proxy service that can be used to distribute updates to client computers. To install Apache HTTP Proxy, read the instructions for Windows, Linux, or Virtual Appliance.


1 Answers

You mentioned load balancing- so presumably you want to be able to add more Application Servers that are served through a single address. I hope they are stateless or storing session information in a database. You can use Apache to serve as a reverse proxy load balancer with mod_proxy_balancer. Docs are here.

Here's an example of what to add to your httpd.conf from this link.

 <Proxy balancer://myclustername>
  # cluster member 1
  BalancerMember http://192.168.0.1:3000 
  BalancerMember http://192.168.0.1:3001

  # cluster member 2, the fastest machine so double the load
  BalancerMember http://192.168.0.11:3000 loadfactor=2
  BalancerMember http://192.168.0.11:3001 loadfactor=2

  # cluster member 3
  BalancerMember http://192.168.0.12:3000
  BalancerMember http://192.168.0.12:3001

  # cluster member 4
  BalancerMember http://192.168.0.13:3000
  BalancerMember http://192.168.0.13:3001
</Proxy>

<VirtualHost *:80>
  ServerAdmin [email protected]
  ServerName www.meinprof.de
  ServerAlias meinprof.de
  ProxyPass / balancer://meinprofcluster/
  ProxyPassReverse / balancer://meinprofcluster/
  ErrorLog /var/log/www/www.meinprof.de/apache_error_log
  CustomLog /var/log/www/www.meinprof.de/apache_access_log combined
</VirtualHost>
like image 71
MattMcKnight Avatar answered Oct 11 '22 15:10

MattMcKnight