karaf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daisuke Otaka <daisuke.ot...@globalway.co.jp>
Subject URL Redirecting by Jetty RewriteHandler
Date Wed, 22 Apr 2015 13:07:47 GMT
Hi,

I'm trying URL redirect by the Jetty RewriteHandler now, but it doesn't work
fine.
Kindly let me know if you have any suggestion.

[Objective]
Redirect request URL from A to B.
A: http://dev:8040/voxer/HelloService
B: http://dev:8040/services/HelloService

[Current Settings]
1. Add bundle file (jar)
/opt/Talend-5.6.1/runtime/system/org/eclipse/jetty/jetty-rewrite/7.6.9.v20130131/jetty-rewrite-7.6.9.v20130131.jar

2. Add bundle setting to my karaf standard feature xml file.
/opt/Talend-5.6.1/runtime/system/org/apache/karaf/assemblies/features/standard/2.3.9/standard-2.3.9-features.xml
-----
    <feature name="jetty" description="Provide Jetty engine support"
version="7.6.9.v20130131" resolver="(obr)">
        <bundle dependency="true"
start-level="30">mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.activation-api-1.1/2.4.0</bundle>
        <bundle dependency="true"
start-level="30">mvn:org.apache.geronimo.specs/geronimo-servlet_2.5_spec/1.2</bundle>
        <bundle dependency="true"
start-level="30">mvn:javax.mail/mail/1.4.5</bundle>
        <bundle dependency="true"
start-level="30">mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle>
        <bundle
start-level="30">mvn:org.eclipse.jetty/jetty-util/7.6.9.v20130131</bundle>
        <bundle
start-level="30">mvn:org.eclipse.jetty/jetty-io/7.6.9.v20130131</bundle>
        <bundle
start-level="30">mvn:org.eclipse.jetty/jetty-http/7.6.9.v20130131</bundle>
        <bundle
start-level="30">mvn:org.eclipse.jetty/jetty-client/7.6.9.v20130131</bundle>
        <bundle
start-level="30">mvn:org.eclipse.jetty/jetty-continuation/7.6.9.v20130131</bundle>
        <bundle
start-level="30">mvn:org.eclipse.jetty/jetty-jmx/7.6.9.v20130131</bundle>
        <bundle
start-level="30">mvn:org.eclipse.jetty/jetty-server/7.6.9.v20130131</bundle>
        <bundle
start-level="30">mvn:org.eclipse.jetty/jetty-security/7.6.9.v20130131</bundle>
        <bundle
start-level="30">mvn:org.eclipse.jetty/jetty-servlet/7.6.9.v20130131</bundle>
        <bundle
start-level="30">mvn:org.eclipse.jetty/jetty-servlets/7.6.9.v20130131</bundle>
        <bundle
start-level="30">mvn:org.eclipse.jetty/jetty-xml/7.6.9.v20130131</bundle>
        <bundle
start-level="30">mvn:org.eclipse.jetty/jetty-webapp/7.6.9.v20130131</bundle>
        <bundle
start-level="30">mvn:org.eclipse.jetty/jetty-jndi/7.6.9.v20130131</bundle>
        <bundle
start-level="30">mvn:org.eclipse.jetty/jetty-plus/7.6.9.v20130131</bundle>
        <bundle
start-level="30">mvn:org.eclipse.jetty/jetty-websocket/7.6.9.v20130131</bundle>
        <bundle
start-level="30">mvn:org.eclipse.jetty/jetty-rewrite/7.6.9.v20130131</bundle>
    </feature>
-----

3. Add "jetty-rewrite.xml" file reference setting.

/opt/Talend-5.6.1/runtime/system/org/apache/karaf/assemblies/features/standard/2.3.9/standard-2.3.9-features.xml
-----
    <feature name="http" description="Implementation of the OSGi HTTP
service" version="2.3.9" resolver="(obr)">
        <configfile
finalname="/etc/jetty.xml">mvn:org.apache.karaf/apache-karaf/2.3.9/xml/jettyconfig</configfile>
        <config name="org.ops4j.pax.web">
            org.osgi.service.http.port=8181
            javax.servlet.context.tempdir=${karaf.data}/pax-web-jsp
           
org.ops4j.pax.web.config.file=${karaf.base}/etc/jetty.xml,${karaf.base}/etc/jetty-rewrite.xml
        </config>
        <feature version="[7.0,8.0)">jetty</feature>
        <bundle
start-level="30">mvn:org.ops4j.pax.web/pax-web-api/1.1.17</bundle>
        <bundle
start-level="30">mvn:org.ops4j.pax.web/pax-web-spi/1.1.17</bundle>
        <bundle
start-level="30">mvn:org.ops4j.pax.web/pax-web-runtime/1.1.17</bundle>
        <bundle
start-level="30">mvn:org.ops4j.pax.web/pax-web-jetty/1.1.17</bundle>
    </feature>
-----

4. Create file "jetty-rewrite.xml"

/opt/Talend-5.6.1/esb/container/etc/jetty-rewrite.xml
-----
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC &quot;-//Mort Bay Consulting//
DTD Configure//EN&quot; &quot;http://jetty.mortbay.org/configure.dtd&quot;>

  <Configure id="Server" class="org.eclipse.jetty.server.Server">

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

      
      <Call name="addRule">
        <Arg>
          <New
class="org.eclipse.jetty.rewrite.handler.RedirectPatternRule">
            <Set name="pattern">/voxer/*</Set>
            <Set name="location">/services/</Set>
          </New>
        </Arg>
      </Call>
    </New>

     
    <Set name="handler"><Ref id="Rewrite" /></Set>

  </Configure>
-----

5. Restart karaf

Best Regards,
Daisuke Otaka




--
View this message in context: http://karaf.922171.n3.nabble.com/URL-Redirecting-by-Jetty-RewriteHandler-tp4039880.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Mime
View raw message