Skip to content

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>

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



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"?>
Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
<!-- -->
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <!-- -->
  <Call name="addAliasCheck">
      <New class="org.eclipse.jetty.server.handler.AllowSymLinkAliasChecker" />
9 People found this is helpful