简体   繁体   English

如何配置Apache作为j2ee服务器的代理(负载均衡器)?

[英]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. 我安装了apache web服务器作为前端,我在Intranet服务器上安装了j2ee SAP Netweaver Application Server。 How can I configure apache to forward requests and response to/from j2ee app server. 如何配置apache以转发请求和响应j2ee应用服务器。 for example, external apache server's ip is 9.20.1.1:80. 例如,外部apache服务器的ip是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 内部sap服务器的地址是192.168.0.1/sap/bc/gui/sap/its/webgui?sap_client=200我想访问我的sap app服务器,例如9.20.1.1/sapserver/sap/bc/gui/sap/its/的WebGUI?SAP_CLIENT = 200

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 . 您可以使用Apache作为mod_proxy_balancer的反向代理负载均衡器。 Docs are here . 文件在这里

Here's an example of what to add to your httpd.conf from this link . 以下是从此链接添加到httpd.conf的示例。

 <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 info@meinprof.de
  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>

This is often mistakenly referred to as a reverse proxy. 这通常被错误地称为反向代理。 If you use a search engine to find "reverse proxy apache" you will get many good results. 如果您使用搜索引擎查找“反向代理apache”,您将获得许多好结果。

The quick answer is to add something like this to your apache.conf 快速回答是在apache.conf中添加这样的内容

ProxyPass /sap/ 192.168.0.1/sap/ ProxyPass / sap / 192.168.0.1/sap/

< Location /sap/ > <位置/ sap />

  ProxyPassReverse /sap/ 

< /Location > </ Location>

See also the modrewrite rools and the [P] option. 另请参见modrewrite rools和[P]选项。

Assuming you have mod_proxy enabled, add to you're sites-available: 假设您已启用mod_proxy,请添加到您的站点 - 可用:

   ProxyRequests Off
   <Location "/sapserver">
        ProxyPass http://192.168.0.1
        ProxyPassReverse http://192.168.0.1
   </Location>

Be careful though as this does expose your internal site to the entire internet. 但要小心,因为这会将您的内部网站暴露给整个互联网。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM