ORDS: Redirection and logging (3.x)

The below is applicable to the ORDS instance running out of DBCS instance running on OCI-classic, on a customized version of ORDS 3.0. For OCI or 18.x version of ORDS, check out this note.

To customize ords by adding logfile and redirection capabilities, for example from ‘/’ to ‘/ords/apps/f?p=100 where is the workspace where the application 100 is running, proceed as follow:

#1 Create or update the file /u01/app/oracle/product/ords/conf/ords/standalone/etc/jetty-http.xml to add the following:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">

<!-- -->
<!-- Rewrite -->
<!-- -->
<Get id="oldhandler" name="handler"/>
 <Set name="handler">
 <New id="Rewrite" class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
 <Set name="handler">
 <Ref refid="oldhandler"/>
 </Set>
 <Set name="rewriteRequestURI">
 <Property name="rewrite.rewriteRequestURI" default="true"/>
 </Set>
 <Set name="rewritePathInfo">
 <Property name="rewrite.rewritePathInfo" default="false"/>
 </Set>
 <Set name="originalPathAttribute">
 <Property name="rewrite.originalPathAttribute" default="requestedPath"/>
 </Set>
 </New>
 </Set>

<!-- -->
<!-- apps redirect -->
<!-- -->
<Ref refid="Rewrite">
 <Call name="addRule"> 
 <Arg> 
 <New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule"> 
 <Set name="pattern">/apps</Set> 
 <Set name="replacement">/ords/apps/f?p=100:1::::::/</Set> 
 </New> 
 </Arg> 
 </Call> 
 <Call name="addRule"> 
 <Arg> 
 <New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule"> 
 <Set name="pattern">^/
lt;/Set> 
 <Set name="replacement">/ords/apps/f?p=100:1::::::/</Set> 
 </New> 
 </Arg> 
 </Call> 
 <Call name="addRule"> 
 <Arg> 
 <New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule"> 
 <Set name="pattern">/index.html</Set> 
 <Set name="replacement">/ords/apps/f?p=100:1::::::/</Set> 
 </New> 
 </Arg> 
 </Call> 
 </Ref>

<!-- -->
<!-- http logs -->
<!-- -->
<Ref id="Handlers">
 <Call name="addHandler">
 <Arg>
 <New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler">
 <Set name="requestLog">
 <New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
 <Set name="filename"><Property name="jetty.logs" default="/tmp/"/>ords-access-yyyy_mm_dd.log</Set>
 <Set name="filenameDateFormat">yyyy_MM_dd</Set>
 <Set name="retainDays">90</Set>
 <Set name="append">true</Set>
 <Set name="extended">false</Set>
 <Set name="logCookies">false</Set>
 <Set name="LogTimeZone">GMT</Set>
 </New>
 </Set>
 </New>
 </Arg>
 </Call>
 </Ref>

</Configure>

#2 Restart ords

sudo /etc/init.d/ords restart

#3 Check the logfile

tail -f /tmp/ords-access-2018_mm_dd.log