首页 > 解决方案 > 在undertow中使用表达式过滤器不起作用

问题描述

我正在使用 Wildfly 10,我正在尝试在 undertow 配置中添加一个表达式过滤器来验证来自 mod_jk 的秘密值。但是,它总是返回错误代码 403。

下面是我在standalone-full.xml 中的配置

<subsystem xmlns="urn:jboss:domain:undertow:7.0" ...>
...
<server name="default-server">
    <http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/>
    <ajp-listener name="ajp" socket-binding="ajp"/>
    <https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>
    <host name="default-host" alias="localhost">
        ...
        <!-- add the following with your AJP port (8009) -->
        <filter-ref name="secret-checker" predicate="equals(%p, 8009)"/>
    </host>
</server>
...
<filters>
    <!-- add the following with your credential (YOUR_AJP_SECRET) -->
    <expression-filter name="secret-checker" expression="not equals(%{r,secret}, 'verysecure') -> response-code(403)"/>
</filters>

下面是 mod_jk 在workers.properties 中的配置。

worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=127.0.0.1
worker.ajp13.type=ajp13
worker.ajp13.secret=verysecure

我正在尝试减轻此链接中详述的 ghostcat 漏洞。 https://access.redhat.com/solutions/4851251

任何帮助表示赞赏。提前致谢。

标签: wildfly-10undertowmod-jk

解决方案


在端口之后放置“ and equals(%{PROTOCOL}, 'AJP')” 。

predicate="equals(%p, 8009) and equals(%{PROTOCOL}, 'AJP')" 但我得到的是 404 而不是预期的 403 :(


推荐阅读