使用 mod_cluster 连接 apache 和 Wildfly

Connecting apache and Widfly using mod_cluster

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

当我尝试使用 ajp 作为协议连接 mod_cluster 和 wildfly 时,我的问题出现了。我检查了 mod_cluster-manager 似乎 mod_cluster连上了wildfly,但是无法转发 请求到应用程序服务器。

我有以下配置:

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 时,它起作用了。我想使用自定义端口号。 有人知道怎么做吗?

原来我有错误的二进制文件:/。将它们替换为官网的后,我成功地通过 AJP 将 Wildfly 与 apache 连接起来。