配置 Jetty 9.2 以允许通过 XML 文件进行符号链接
Configuring Jetty 9.2 to allow symlinks through XML file
我的设置有点复杂,因为我将 JRuby 与 Warbler 结合使用,后者在底层使用 Jetty 9.2.9。
现在,the docs for enabling symlinks in 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.xml
其中有 <web-app>
个元素
webserver.xml
其中有 <Configure class="org.eclipse.jetty.server.Server">
个元素
webserver.properties
为 Jetty runner 定义了一堆参数
所以我的问题是,如果只能访问这三个文件(并且可能能够将更多文件添加到 WEB-INF
目录),我怎样才能使 Jetty 遵循符号链接?
Uff,好吧,显然如果我需要配置 WebAppContext,我只需将 jetty-web.xml
添加到我的 WEB-INF
文件夹和 Jetty will automatically use it.
所以最后我的 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>
我的设置有点复杂,因为我将 JRuby 与 Warbler 结合使用,后者在底层使用 Jetty 9.2.9。
现在,the docs for enabling symlinks in 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.xml
其中有<web-app>
个元素webserver.xml
其中有<Configure class="org.eclipse.jetty.server.Server">
个元素webserver.properties
为 Jetty runner 定义了一堆参数
所以我的问题是,如果只能访问这三个文件(并且可能能够将更多文件添加到 WEB-INF
目录),我怎样才能使 Jetty 遵循符号链接?
Uff,好吧,显然如果我需要配置 WebAppContext,我只需将 jetty-web.xml
添加到我的 WEB-INF
文件夹和 Jetty will automatically use it.
所以最后我的 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>