简体   繁体   English

Apache httpd作为jboss和其他Apache服务器的负载平衡器

[英]Apache httpd as load balancer for jboss as well another Apache servers

I have an apache httpd server, say server1* (publicly exposed) that is acting as load balancer for some jboss servers(behind firewall) using mod_cluster. 我有一个Apache httpd服务器,例如server1 *(公开),它使用mod_cluster充当某些jboss服务器(在防火墙后)的负载平衡器。 Now I want to install my static content (images/css/htmls) and probably some cg-scripts on a couple of apache servers, say **server2 and server3 (behind firewall). 现在,我想在几台apache服务器上安装我的静态内容(images / css / htmls)以及一些cg脚本,例如** server2server3 (位于防火墙后)。

Now I want server1 to act as load balancer for these server2 and server3 as well along with the jboss servers. 现在,我希望server1以及jboss服务器充当这些server2和server3的负载平衡器。

With this arrangement, any request for applications deployed on jboss need to be routed to jboss and any static content request should go to server2 or server3 . 通过这种安排,需要将对部署在jboss上的应用程序的任何请求都路由到jboss,并且任何静态内容请求都应发送到server2server3

Here are the versions I am using 这是我正在使用的版本

Linux Server apache httpd - 2.2.22 JBOSS-EAP-6 Linux服务器apache httpd-2.2.22 JBOSS-EAP-6

What mechanism/configuration do I need to use in server1 to make it possible? 我需要在server1中使用什么机制/配置才能实现? Please see if someone can help with this. 请查看是否有人可以帮助您。

Well, you just add a ProxyPass setting. 好吧,您只需添加一个ProxyPass设置。 mod_cluster is compatible with ProxyPass, so you can use both. mod_cluster与ProxyPass兼容,因此您可以同时使用两者。

For instance, if I would like gif images to be served by httpd, not by AS7, I can add: 例如,如果我希望gif图片由httpd而不是AS7提供,则可以添加:

ProxyPassMatch ^(/.*\.gif)$ !  

Furthermore, if you set 此外,如果您设置

CreateBalancers 1

mod_cluster won't create proxies for you and you have to do it yourself. mod_cluster不会为您创建代理,您必须自己做。 This gives you an additional control. 这为您提供了额外的控制。 For instance: 例如:

ProxyPassMatch ^/static/ !
ProxyPass / balancer://qacluster stickysession=JSESSIONID|jsessionid nofailover=on
ProxyPassReverse / balancer://qacluster
ProxyPreserveHost on

In the aforementioned example, we proxy anything but /static/ content to the workers. 在上述示例中,我们将/ static /内容以外的任何内容代理给工作人员。

  • Note:If you encounter any cookies related issues, you might want to play with ProxyPassReverseCookieDomain and ProxyPassReverseCookiePath. 注意:如果遇到与Cookie相关的任何问题,则可能需要使用ProxyPassReverseCookieDomain和ProxyPassReverseCookiePath。

  • Note qacluster in my config. 注意我的配置中的qacluster The default is mycluster , so for naming my balancer qacluster, I added this to mod_cluster config (outside VirtualHost): 默认值为mycluster ,因此为了命名我的平衡器qacluster,我将其添加到mod_cluster config(在VirtualHost外部):

     ManagerBalancerName qacluster 

If it is not clear, just reply and I can try to elaborate further. 如果不清楚,请回复,我可以尝试进一步阐述。

I had the same issue where in we were using Apache HTTP server for static content and JBOSS AS 7 server for dynamic contents (the JSF web app). 在使用Apache HTTP服务器获取静态内容和使用JBOSS AS 7服务器获取动态内容(JSF Web应用程序)时,我遇到了同样的问题。

So adding the below property at the end of Load modules tells 因此,在Load模块末尾添加以下属性可以说明

CreateBalancers 0   

Tells to "0: Create in all VirtualHosts defined in httpd." 告诉“ 0:在httpd中定义的所有VirtualHost中创建”。

More at: http://docs.jboss.org/mod_cluster/1.2.0/html/native.config.html#d0e485 有关更多信息,请访问: http : //docs.jboss.org/mod_cluster/1.2.0/html/native.config.html#d0e485

And the below config solved the issues of images and styel sheets not getting displayed. 并且以下配置解决了图像和样式表无法显示的问题。

<VirtualHost *:80>
  ServerName dev.rama.com
  DocumentRoot "/var/www/assests"
  UseAlias 1
  ProxyPassMatch ^(.*\.bmp)$ !
  ProxyPassMatch ^(.*\.css)$ !
  ProxyPassMatch ^(.*\.gif)$ !
  ProxyPassMatch ^(.*\.jpg)$ !
  ProxyPassMatch ^(.*\.js)$ !
  ProxyPassMatch ^(.*\.png)$ !
 <Directory /var/www/assests>
   Options Indexes FollowSymLinks
   AllowOverride None
   Order allow,deny
   Allow from all
 </Directory>

Note: All our assests for the web app was on HTTP server at /var/www/assests and the url I was accessing was dev.rama.com on port 80 注意:我们对Web应用程序的所有支持都在/ var / www / assests的HTTP服务器上,而我正在访问的URL是端口80上的dev.rama.com。

So when it sees this ProxyPassMatch ^(.*.css)$ ! 因此,当它看到此ProxyPassMatch ^(。*。css)$时! The webserver knows that the css files are local to the http server and we dont need to go to Jboss App server. 网络服务器知道css文件是http服务器本地的,我们不需要转到Jboss App服务器。

More info at http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass 有关更多信息, 访问http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass

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

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