Skip to content
Advertisement

Configuring Jetty 9.2 to allow symlinks through XML file

My setup is a bit complicated, as I use JRuby with Warbler which uses Jetty 9.2.9 underneath.

Now, the docs for enabling symlinks in Jetty tell you to add this to WEB-INF/jetty-web.xml:

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

However, as far as I can tell from searching through XML files on GitHub which use AllowSymLinkAliasChecker, this snippet has to be used within a <Configure id="wac" class="org.eclipse.jetty.webapp.WebAppContext"> element.

Through Warbler I have access to only three files:

  • web.xml which has <web-app> element
  • webserver.xml which has <Configure class="org.eclipse.jetty.server.Server"> element
  • webserver.properties which defines a bunch of args for the Jetty runner

So my question is, with access to only these three files (and possibly being able to add more of them to the WEB-INF directory), how can I make Jetty follow symlinks?

Advertisement

Answer

Uff, okay, so apparently if I need to configure WebAppContext, I can just add jetty-web.xml to my WEB-INF folder and Jetty will automatically use it.

So in the end my jetty-web.xml looks like this:

<?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>
Advertisement