第 6 章 服务器迁移更改


在迁移前,请确保您了解在服务器上部署应用程序所需的迁移更改,并在 Red Hat JBoss Enterprise Application Platform 8.0 中升级它们。

6.1. Web 服务器配置更改

了解 Red Hat JBoss Enterprise Application Platform 中 mod_cluster 和 Undertow 的更改,它们会影响根上下文行为并增强服务器信息的安全性。

6.1.1. 默认 Web 模块行为更改

在 JBoss EAP 7.0 中,mod_cluster 中默认禁用 Web 应用的根上下文。

自 JBoss EAP 7.1 起,情况已不再如此。如果您希望禁用根上下文,这可能会造成意外的后果。例如,可以将请求错误路由到不合要求的节点,或者不应公开的私有应用可以通过公共代理意外访问。Undertow 位置现在会自动注册到 mod_cluster 负载平衡器,除非它们被明确排除。

使用以下管理 CLI 命令,将 ROOT 从 modcluster 子系统配置中排除:

/subsystem=modcluster/mod-cluster-config=configuration:write-attribute(name=excluded-contexts,value=ROOT)
Copy to Clipboard Toggle word wrap

使用以下管理 CLI 命令,禁用默认的欢迎 Web 应用:

/subsystem=undertow/server=default-server/host=default-host/location=\/:remove
/subsystem=undertow/configuration=handler/file=welcome-content:remove
reload
Copy to Clipboard Toggle word wrap

6.1.2. Undertow 子系统默认配置更改

在 Red Hat JBoss Enterprise Application Platform 7.2 之前,默认的 undertow 子系统配置包括两个响应标头过滤器,这些标头被 default-host 附加到每个 HTTP 响应中:

  • server 之前已设置为 JBoss EAP/7
  • X-Powered-By 之前设置为 Undertow/1

这些响应标头过滤器已从默认的 JBoss EAP 7.2 配置中删除,以防止意外泄漏有关正在使用的服务器的信息。

以下是 JBoss EAP 7.1 中默认 undertow 子系统配置的示例。

<subsystem xmlns="urn:jboss:domain:undertow:4.0">
    <buffer-cache name="default"/>
    <server name="default-server">
        <http-listener name="default" socket-binding="http" redirect-socket="https"/>
        <https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>
        <host name="default-host" alias="localhost">
            <location name="/" handler="welcome-content"/>
            <filter-ref name="server-header"/>
            <filter-ref name="x-powered-by-header"/>
            <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"/>
    </filters>
</subsystem>
Copy to Clipboard Toggle word wrap

以下是 JBoss EAP 7.4 中默认 undertow 子系统配置的示例:

<subsystem xmlns="urn:jboss:domain:undertow:12.0" default-server="default-server" default-virtual-host="default-host" default-servlet-container="default" default-security-domain="other">
    <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"/>
        <host name="default-host" alias="localhost">
            <location name="/" handler="welcome-content"/>
            <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>
</subsystem>
Copy to Clipboard Toggle word wrap

以下是 JBoss EAP 8.0 中默认 undertow 子系统配置的示例。

<subsystem xmlns="urn:jboss:domain:undertow:14.0" default-virtual-host="default-host" default-servlet-container="default" default-server="default-server" statistics-enabled="${wildfly.undertow.statistics-enabled:${wildfly.statistics-enabled:false}}" default-security-domain="other">
    <byte-buffer-pool name="default"/>
    <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" ssl-context="applicationSSC" enable-http2="true"/>
        <host name="default-host" alias="localhost">
            <location name="/" handler="welcome-content"/>
            <http-invoker http-authentication-factory="application-http-authentication"/>
        </host>
    </server>
    <servlet-container name="default">
        <jsp-config/>
        <websockets/>
    </servlet-container>
    <handlers>
        <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
    </handlers>
    <application-security-domains>
        <application-security-domain name="other" security-domain="ApplicationDomain"/>
    </application-security-domains>
</subsystem>
Copy to Clipboard Toggle word wrap
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部