2017-04-13 120 views
1

我试图设置mod_cluster作为Wildfly 9的反向代理。当我使用http作为协议(mod_cluster和Wildfly之间的协议)时,一切正常(将请求转发到应用程序服务器和检测服务器)。使用mod_cluster连接Apache和Widfly

当我尝试使用ajp作为协议来连接mod_cluster和wildfly时,出现了我的问题。我检查了mod_cluster-manager,看起来好像 mod_cluster已连接到wildfly,但它不能将 请求转发给应用服务器。

我具有以下配置:

  • http服务器:阿帕奇/ 2.4.18(Ubuntu的)
  • 应用服务器:Wildfly 9.0.2
  • mod_cluster:1.3

mod_cluster .conf

PersistSlots on 
CreateBalancers 1 
MemManagerFile /opt/mod_cluster/logs 


EnableOptions 
AllowDisplay On 
AllowCmd On 
WaitForRemove 1 



UseAlias 1 
ServerAdvertise Off 

Listen *:5555 
<VirtualHost *:5555> 
    <Directory /> 
     Order deny,allow 
     Allow from 192.168.0.71 
     Allow from 192.168.0.71 
     Allow from 127 
     Require all granted 
    </Directory> 
    <Location /mcm> 
     SetHandler mod_cluster-manager 
     Allow from 192.168 
     Allow from all 
    </Location> 
    KeepAliveTimeout 300 
    MaxKeepAliveRequests 0 
    ManagerBalancerName mycluster 
    #AdvertiseFrequency 5 
    EnableMCPMReceive 

</VirtualHost> 



<VirtualHost *:80> 

    ServerName my-app.org 
    ServerAlias my-app.org 
    ErrorLog /var/log/apache2/user.error.log 
    LogLevel warn 
    CustomLog /var/log/apache2/my_app.access.log combined 
    ServerSignature On 

    Redirect "/" https://my-app.org 
    ProxyPreserveHost On 
    SSLProxyEngine On 
    ProxyPreserveHost On 
    #ProxyPass /_error ! 
    #ProxyPass/balancer://mycluster stickysession=JSESSIONID|jsessionid nofailover=on 
    #ProxyPassReverse/balancer://mycluster 


    <Location /> 
     Order deny,allow 
     Allow from all 
    </Location> 

</VirtualHost> 

<VirtualHost *:443> 

    ServerName my-app.org 
    ServerAlias my-app.org 
    SSLEngine on 
    SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem 
    SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key 
    ErrorLog /var/log/apache2/user.ssl.error.log 
    LogLevel warn 
    CustomLog /var/log/apache2/my_app.ssl.access.log combined 
    ServerSignature On 

    SSLProxyEngine On 
    ProxyPreserveHost On 
    ProxyPass /_error ! 
    ProxyPass/balancer://mycluster stickysession=JSESSIONID|jsessionid nofailover=on 
    ProxyPassReverse/balancer://mycluster 
    <Location /> 
     Order deny,allow 
     Allow from all 
    </Location> 
</VirtualHost> 

Wildfly配置(相关片段):

mod_cluster子系统:

<subsystem xmlns="urn:jboss:domain:modcluster:2.0"> 
     <mod-cluster-config advertise-socket="modcluster" 
          proxies="mc-prox1" 
          advertise="false" 
          sticky-session-force="true" load-balancing-group="mycluster" connector="ajp"> 
      <dynamic-load-provider> 
       <load-metric type="cpu"/> 
      </dynamic-load-provider> 
     </mod-cluster-config> 
    </subsystem> 

出站套接字绑定:

<outbound-socket-binding name="mc-prox1"> 
     <remote-destination host="192.168.0.71" port="5555"/> 
    </outbound-socket-binding> 

[编辑]

我应包括AJP配置:

<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:1500}"> 
    <socket-binding name="ajp" port="${jboss.ajp.port:0}" /> 
....... 
</socket-binding-group> 

[EDIT2]

当我设置ajp端口为8009,它的工作原理。我想使用自定义端口号。 有没有人有线索如何做到这一点?

回答

0

原来我有错误的二进制文件:/。将它们替换为官方网站上的代码后,我设法通过AJP将Wildfly与apache连接起来。