4.4.2. 迁移 JBoss Web 重写条件
管理 CLI 的 migrate 操作无法自动迁移重写条件,它们被报告为“migration-warnings”,您必须手动迁移它们。在 JBoss EAP 7 里,您可以用 Undertow Predicates Attributes and Handlers 创建同等的配置。
下面是 JBoss EAP 6 里包含 rewrite 配置的默认 web 子系统配置示例。
按照 Management CLI Migration Operation 说明启动服务器和管理 CLI,然后用下列命令迁移 web 子系统配置文件。/subsystem=web:migrate
当您对上述配置运行 migrate 操作时会出现下面的 "migration-warnings" 信息。/subsystem=web:migrate
{
"outcome" => "success",
"result" => {"migration-warnings" => [
"WFLYWEB0002: Could not migrate resource {
\"pattern\" => \"(.*)\",
\"substitution\" => \"-\",
\"flags\" => \"F\",
\"operation\" => \"add\",
\"address\" => [
(\"subsystem\" => \"web\"),
(\"virtual-server\" => \"default-host\"),
(\"rewrite\" => \"test2\")
]
}",
"WFLYWEB0002: Could not migrate resource {
\"test\" => \"%{REQUEST_METHOD}\",
\"pattern\" => \"GET\",
\"flags\" => undefined,
\"operation\" => \"add\",
\"address\" => [
(\"subsystem\" => \"web\"),
(\"virtual-server\" => \"default-host\"),
(\"rewrite\" => \"test2\"),
(\"condition\" => \"get\")
]
}",
"WFLYWEB0002: Could not migrate resource {
\"test\" => \"%{REQUEST_URI}\",
\"pattern\" => \".*index.html\",
\"flags\" => \"NC\",
\"operation\" => \"add\",
\"address\" => [
(\"subsystem\" => \"web\"),
(\"virtual-server\" => \"default-host\"),
(\"rewrite\" => \"test2\"),
(\"condition\" => \"andCond\")
]
}"
]}
}
复查服务器配置文件,您会看到 undertow 子系统的下列配置。
注意
重写(Rewrite)配置已被舍弃。
使用管理 CLI 创建过滤器来替换 undertow 子系统里的重写配置。每个命令您都应该看到 "{"outcome" ⇒ "success"}" 信息。# Create the filters
/subsystem=undertow/configuration=filter/expression-filter="test1":add(expression="path('(.*)/toberewritten/(.*)') -> rewrite('$1/rewritten/$2')")
/subsystem=undertow/configuration=filter/expression-filter="test2":add(expression="method('GET') and path('.*index.html') -> response-code(403)")
# Add the filters to the default server
/subsystem=undertow/server=default-server/host=default-host/filter-ref="test1":add
/subsystem=undertow/server=default-server/host=default-host/filter-ref="test2":add
复查已更新的服务器配置文件。JBoss Web 子系统现在已完全迁移且已配置了 undertow 子系统。
关于如何用管理 CLI 配置过滤器和处理程序的更多信息,请参考《JBoss EAP 7 配置指南》 里的 Configuring the Web Server。