配置Jetty 9.2允许通过XML文件进行符号链接



我的设置有点复杂,因为我使用JRuby和Warbler,它使用Jetty 9.2.9。

现在,在Jetty中启用符号链接的文档告诉您将其添加到WEB-INF/jetty-web.xml:

<!-- Allow symbolic links  -->
<Call name="addAliasCheck">
<Arg><New class="org.eclipse.jetty.server.handler.AllowSymLinkAliasChecker"/></Arg>
</Call>

然而,据我所知,通过搜索GitHub上使用AllowSymLinkAliasChecker的XML文件,这个片段必须在<Configure id="wac" class="org.eclipse.jetty.webapp.WebAppContext">元素中使用。

通过Warbler我只能访问三个文件:

  • 含有<web-app>元素的web.xml
  • 包含<Configure class="org.eclipse.jetty.server.Server">元素的webserver.xml
  • webserver.properties为Jetty runner定义了一堆参数

所以我的问题是,只能访问这三个文件(并且可能能够将更多的文件添加到WEB-INF目录),我如何使Jetty遵循符号链接?

Uff,好的,所以显然,如果我需要配置WebAppContext,我可以把jetty-web.xml添加到我的WEB-INF文件夹,Jetty会自动使用它。

最后我的jetty-web.xml是这样的:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE 
Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
"http://www.eclipse.org/jetty/configure.dtd">
<!-- https://www.eclipse.org/jetty/documentation/jetty-9/index.html#jetty-web-xml-config -->
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<!-- https://www.eclipse.org/jetty/documentation/jetty-9/index.html#file-alias-serving -->
<Call name="addAliasCheck">
<Arg>
<New class="org.eclipse.jetty.server.handler.AllowSymLinkAliasChecker" />
</Arg>
</Call>
</Configure>

相关内容