17.7. 配置默认欢迎 Web 应用
JBoss EAP 包括一个默认的 Welcome
应用,它默认显示在端口 8080 上的根上下文中。
Undertow 中预先配置了默认的服务器,提供欢迎内容。
默认 Undertow 子系统配置
<subsystem xmlns="urn:jboss:domain:undertow:3.1"> ... <server name="default-server"> <http-listener name="default" socket-binding="http" redirect-socket="https"/> <host name="default-host" alias="localhost"> <location name="/" handler="welcome-content"/> <filter-ref name="server-header"/> <filter-ref name="x-powered-by-header"/> </host> </server> ... <handlers> <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/> </handlers> ... </subsystem>
默认服务器(default-server
)配置了默认主机(默认主机
)。默认主机被配置为通过 welcome-content
文件处理程序处理对服务器 root 的请求,使用 <location
> 元素。welcome-content
处理程序在 path
属性中指定的位置提供内容。
此默认 Welcome
应用可以替换为您自己的 Web 应用。这可以通过以下两种方式之一进行配置:
您还可以 禁用欢迎内容。
更改 welcome-content 文件处理程序
修改现有的 welcome-content
文件处理程序的路径以指向新部署。
/subsystem=undertow/configuration=handler/file=welcome-content:write-attribute(name=path,value="/path/to/content")
注意
或者,您可以创建不同的文件处理程序,供服务器的 root 使用。
/subsystem=undertow/configuration=handler/file=NEW_FILE_HANDLER:add(path="/path/to/content") /subsystem=undertow/server=default-server/host=default-host/location=\/:write-attribute(name=handler,value=NEW_FILE_HANDLER)
重新加载服务器以使更改生效。
reload
更改 default-web-module
将部署的 Web 应用映射到服务器的根目录。
/subsystem=undertow/server=default-server/host=default-host:write-attribute(name=default-web-module,value=hello.war)
重新加载服务器以使更改生效。
reload
禁用默认欢迎 Web 应用程序
删除 default-host
的位置
条目/
,以禁用 welcome 应用。
/subsystem=undertow/server=default-server/host=default-host/location=\/:remove
重新加载服务器以使更改生效。
reload