17.9. 配置默认欢迎 Web 应用程序
JBoss EAP 包含一个默认的 Welcome
应用,默认显示在端口 8080
的根上下文中。
Undertow 中预配置了默认服务器,可提供欢迎内容。
默认 Undertow 子系统配置
<subsystem xmlns="urn:jboss:domain:undertow:10.0" default-server="default-server" default-virtual-host="default-host" default-servlet-container="default" default-security-domain="other"> ... <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> ... <handlers> <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/> </handlers> </subsystem>
默认服务器 default-server
配置了默认主机 default-host
。默认主机被配置为使用 <location>
元素和 welcome-content
文件处理程序来处理对服务器的 root 的请求。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