Ubuntu 14.04, Apache2, Lucee 4.5 and URLRewrite

260 views
Skip to first unread message

tnoe

unread,
Oct 19, 2015, 1:51:56 PM10/19/15
to CFWheels
Hi all,

Working on a development environment with Lucee (Tomcat).  Everything is up and running, except for URL rewriting.  Have followed the instruction on the CFWheels site for URL rewriting with Apache, still no luck.  There are a few other posts around the interwebs about getting URL Rewriting working through Apache and Tomcat, but still not having any luck.

Has anybody got any (simplified) steps to get this working?

Thanks,
Todd

Tom King

unread,
Oct 19, 2015, 2:24:20 PM10/19/15
to CFWheels
This is on centos7 + apache 2.4 + lucee 4.5;

In /etc/httpd/conf/httpd.d (i.e, your main apache config file) I've added

After:
Include conf.modules.d/*.conf
LoadModule rewrite_module modules/mod_rewrite.so

In /etc/httpd/conf.d/vhosts.conf (i.e, where you might have v hosts defined), added:

RewriteEngine on 
DirectoryIndex  rewrite.cfm index.cfm index.html

And for each site:

<VirtualHost *:80> 
    ServerName www.foo.co.uk 
    DocumentRoot /var/www/foo/html/public  
    <Directory  "/var/www/foo/html/public">
  Options Indexes FollowSymLinks
    Require all granted
        AllowOverride All
    </Directory>
</VirtualHost>   
 
In /opt/lucee/tomcat/conf/web.xml

I've added rewrite.cfm:

ie.
    <!-- Mappings for the Lucee servlet -->
    <servlet-mapping>
        <servlet-name>CFMLServlet</servlet-name>
        <url-pattern>*.cfm</url-pattern>
        <url-pattern>*.cfml</url-pattern>
        <url-pattern>*.cfc</url-pattern>
<!-- Basic SES Mappings -->
<url-pattern>/index.cfc/*</url-pattern>
<url-pattern>/index.cfm/*</url-pattern>
<url-pattern>/rewrite.cfm/*</url-pattern>
<url-pattern>/index.cfml/*</url-pattern>
    </servlet-mapping>

Then restart everything.

That works for me, YMMV.

tnoe

unread,
Oct 22, 2015, 1:27:17 PM10/22/15
to CFWheels
Thanks, Tom. 

I'm on Ubuntu 14.04, Apache 2.4.7, and Lucee 4.5.1.022.  What I tried is:

/etc/apache2/apache2.conf

<Directory>

    Options Indexes FollowSymLinks
    Require all granted
    AllowOverride All
</Directory>

/opt/lucee/tomcat/conf/web.xml

Added <url-pattern>/rewrite.com/*</url-pattern> to the <servlet-mapping> section.

modcfml.load and rewrite.load are in /etc/apache2/mods-enabled

I'm using /opt/lucee/tomcat/webapps/ROOT as my default directory (only site on this server) and visiting it using the server:8888 address, so the ProxyPass stuff in apache2.conf shouldn't really matter.

Still not working - any suggestions?

Thanks,
Todd

Tom King

unread,
Oct 22, 2015, 2:01:55 PM10/22/15
to CFWheels
If you're using 8888 you're bypassing Apache; thus bypassing mod_rewrite etc. So that won't work.

If you want to do URL rewriting in Tomcat on port 8888, you'd have to use Tuckey (http://www.tuckey.org/urlrewrite/) - i.e using this: https://gist.github.com/neokoenig/8e3802cd14387a6ddb82 

Tuckey's not officially supported by cfwheels (although it does work with some fiddling), so I'd definitely try Port 80 -> Apache, Proxy to Tomcat on 8888

T

tnoe

unread,
Oct 23, 2015, 5:11:22 PM10/23/15
to CFWheels
That was it exactly.  I got it working through Apache.  Here's what I did (this is going to be the only site on the server):

Edit the default site config:
vi /etc/apache2/sites-enabled/000-default.conf
Add the following above the </VirtualHost> tag:

    <Directory  "/var/www/html">

     Options Indexes FollowSymLinks
        Require all granted
        AllowOverride All
    </Directory>

Edit the default directory config:
vi /etc/apache2/monds-enabled/dir.conf
Add rewrite.cfm and index.cfm to the DirectoryIndex entry:

<IfModule mod_dir.c>
        DirectoryIndex rewrite.cfm index.cfm index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>

Edit /opt/lucee/tomcat/conf/web.xml.  Make sure the <servlet-mapping> section looks like this.  Take note
of the 2nd to last line, which adds rewrite.cfm.


    <servlet-mapping>
        <servlet-name>CFMLServlet</servlet-name>
        <url-pattern>*.cfm</url-pattern>
        <url-pattern>*.cfml</url-pattern>
        <url-pattern>*.cfc</url-pattern>
    <!-- Basic SES Mappings -->
    <url-pattern>/index.cfc/*</url-pattern>
    <url-pattern>/index.cfm/*</url-pattern>   
    <url-pattern>/rewrite.cfm/*</url-pattern>
    <url-pattern>/index.cfml/*</url-pattern>
    </servlet-mapping>


restart apache:  service apache2 restart

restart lucee:  ./opt/lucee/lucee_ctl restart

Upload CFWheels site to /var/www/html




Thanks for your help, Tom!

Neo Ramos

unread,
Oct 27, 2015, 11:14:45 AM10/27/15
to CFWheels
Hello Todd,

It looks like you've solve your issue.
However, here is another alternative.

You can user Tuckey URL rewriter (http://www.tuckey.org/urlrewrite/).
It's very light and works perfectly with Tomcat (no need for apache web server).
Installation is easy.

I've worked on a few projects using Tomcat, Railo 4 and Tuckey and it has worked really well.

Here is an example of the urlrewrite.xml file:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN" "http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
<!--
    Configuration file for UrlRewriteFilter
    http://www.tuckey.org/urlrewrite/
-->

<urlrewrite>
   
<rule>
       
<condition name="host" operator="equal">xyz.domain.com</condition>
       
<to type="permanent-redirect">http://zyz.domain.com</to>
   
</rule>
 
<rule enabled="true">
 
<condition type="request-uri" operator="notequal">(?i)^/(empty.html|index.cfm|robots.txt|test|osd.xml|flex2gateway|cfide|cfformgateway|flashservices|crossdomain.xml|lib/|cdn|src|includes|favicon\.ico)</condition>
 
<from>^/(.*)$</from>
 
<to type="passthrough">/index.cfm/$1</to>
 
</rule>
</urlrewrite>


Hope this helps.

Thanks, Neo

Reply all
Reply to author
Forward
0 new messages