Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: move configuration off the wiki, and point to the one in svn which is guaranteed to be updated

...

  1. VirtualHostRuleContainer
    Groups rules that apply only to a specific virtual host or a set of virtual hosts
  2. LowThreadsRuleContainer
    Contains rules that are executed when the thread pool is low on threads. For example, you can choose to or send an error code or redirect the response.

Sample Configuration

Below There is a sample configuration for jetty-rewrite.xml. A more complete example can be found in the $JETTY_HOME/etc/jetty-rewrite.xml.

...


<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure id="Server" class="org.mortbay.jetty.Server">
<!-- =========================================================== -->
    <!-- RewriteHandler Sample Configuration                         -->
    <!-- =========================================================== -->
    <!-- Set it to old handler the handler specified in jetty.xml -->
    <Get id="oldhandler" name="handler"/>

    <Set name="handler">
     <New id="Rewrite" class="org.mortbay.jetty.handler.rewrite.RewriteHandler">
      <Set name="handler"><Ref id="oldhandler"/></Set>
      <Set name="rewriteRequestURI">true</Set>
      <Set name="rewritePathInfo">false</Set>
      <Set name="originalPathAttribute">requestedPath</Set>

      <!-- Add rule to protect against IE ssl bug -->
      <Call name="addRule">
        <Arg>
          <New class="org.mortbay.jetty.handler.rewrite.MsieSslRule"/>
        </Arg>
      </Call>

      <!-- protect favicon handling -->
      <Call name="addRule">
        <Arg>
          <New class="org.mortbay.jetty.handler.rewrite.HeaderPatternRule">
	    <Set name="pattern">/favicon.ico</Set>
	    <Set name="name">Cache-Control</Set>
      	    <Set name="value">Max-Age=3600,public</Set>
      	    <Set name="terminating">true</Set>
          </New>
        </Arg>
      </Call>

      <!-- use legacy API for some rewrites -->
      <Call name="addRewriteRule">
      	<Arg>/some/old/context/*</Arg>
      	<Arg>/test/dump/newcontext</Arg>
      </Call>
      <Call name="addRewriteRule">
      	<Arg>/test/dump/rewrite/*</Arg>
      	<Arg>/test/dump/rewritten</Arg>
      </Call>
      <Call name="addRewriteRule">
      	<Arg>/test/dump/rewrite/protect/*</Arg>
      	<Arg/>
      </Call>
      <Call name="addRewriteRule">
      	<Arg>/test/*</Arg>
      	<Arg/>
      </Call>
      <Call name="addRewriteRule">
      	<Arg>/*</Arg>
      	<Arg>/test</Arg>
      </Call>

      <!-- add a regex rule -->
      <Call name="addRule">
        <Arg>
          <New class="org.mortbay.jetty.handler.rewrite.RewriteRegexRule">
            <Set name="regex">/test/dump/regex/([^/]*)/(.*)</Set>
            <Set name="replacement">/test/dump/$2/$1</Set>
          </New>
        </Arg>
      </Call>
     </New>
    </Set>
</Configure>


To use this configuration, include the configuration file during jetty startup. Example below.file provided. To use this configuration, install the rewrite handler, so that it will copy files to the proper locations,

Code Block

cd $JETTY_HOME/contrib/jetty-rewrite-handler
mvn install

then include the configuration file during jetty startup:

Code Block
java -jar start.jar etc/jetty.xml etc/jetty-rewrite.xml
Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery