在 undertow 中配置过滤器以应用某些 http 响应 header 时, header 仅出现在 http 和 https 端口,而不出现在 management-http 和 management-https 端口。有什么方法可以为管理控制台配置相同的内容吗?以下是我目前的配置
<subsystem xmlns="urn:jboss:domain:undertow:7.0">
<buffer-cache name="default"/>
<server name="default-server">
<http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/>
<https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true" enabled-protocols="TLSv1.2" />
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
<filter-ref name="x-xss-protection"/>
<filter-ref name="x-content-type-options"/>
<filter-ref name="strict-transport-security"/>
<http-invoker security-realm="ApplicationRealm"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
</handlers>
<filters>
<response-header name="server-header" header-name="Server" header-value="JBoss-EAP/7"/>
<response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
<response-header name="x-xss-protection" header-name="X-XSS-Protection" header-value="1; mode=block"/>
<response-header name="x-content-type-options" header-name="X-Content-Type-Options" header-value="nosniff"/>
<response-header name="strict-transport-security" header-name="Strict-Transport-Security" header-value="max-age=31536000; includeSubDomains"/>
</filters>
</subsystem>
最佳答案
此功能在 JBOSS EAP 7.3 中可用。对于独立模式配置,
<management-interfaces>
<http-interface security-realm="ManagementRealm">
<http-upgrade enabled="true"/>
<socket-binding http="management-http"/>
<constant-headers>
<header-mapping path="/management">
<header name="X-Header" value="HeaderValue"/>
</header-mapping>
<header-mapping path="/management">
<header name="Y-Header" value="HeaderValue2"/>
</header-mapping>
</constant-headers>
</http-interface>
</management-interfaces>
对于host.xml中的域模式配置,
<management-interfaces>
<http-interface security-realm="ManagementRealm">
<http-upgrade enabled="true"/>
<socket interface="management" port="${jboss.management.http.port:9990}"/>
<constant-headers>
<header-mapping path="/management">
<header name="X-Header" value="HeaderValue"/>
</header-mapping>
<header-mapping path="/management">
<header name="Y-Header" value="HeaderValue2"/>
</header-mapping>
</constant-headers>
</http-interface>
</management-interfaces>
关于http - 为 Jboss 管理控制台 URL 配置 HTTP header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63034321/