Skip to main content
February 8, 2008
Question

How to configure CF8 to process all URL requests?

  • February 8, 2008
  • 1 reply
  • 951 views
Configuration: Apache frontend, ColdfusionMX 8 application server

My Application.cfc defines a cffunction OnRequestStart to check every URL (to ensure user is allowed access).
The function works fine for .cfm files (because the jrun-handler specifies .cfm files).

However I need every URL sent to Apache that contains a specific url-pattern (e.g. /secureMe/*) to be forwarded on to Coldfusion so that the OnRequestStart function will check for user access.

How do I configure Coldfusion (e.g. jrun-handler, web.xml, jrun-web.xml) to process every URL?

I've tried <servlet-mapping> and <virtual-mapping> and even tried out CFFileServlet but I cannot get Coldfusion to do anything with directories and non-cfm files.

Any solutions and suggestions would be greatly appreciated.
    This topic has been closed for replies.

    1 reply

    Inspiring
    February 8, 2008
    devodl wrote:
    > Configuration: Apache frontend, ColdfusionMX 8 application server
    >
    > My Application.cfc defines a cffunction OnRequestStart to check every URL (to
    > ensure user is allowed access).
    > The function works fine for .cfm files (because the jrun-handler specifies
    > .cfm files).
    >
    > However I need every URL sent to Apache that contains a specific url-pattern
    > (e.g. /secureMe/*) to be forwarded on to Coldfusion so that the OnRequestStart
    > function will check for user access.
    >
    > How do I configure Coldfusion (e.g. jrun-handler, web.xml,
    > jrun-web.xml) to process every URL?

    First you configure the webserver connector to send everything to JRun.
    Pu the following in web.xml
    <servlet-mapping>
    <servlet-name>CfmServlet</servlet-name>
    <url-pattern>/secureMe/*</url-pattern>
    </servlet-mapping>

    The use a utility like http://tuckey.org/urlrewrite/ to rewrite URLs
    from /secureMe/* to /secureMe/index.cfm/* and then in index.cfm put a
    cfcontent tag that sends the requested file.

    Or do both at the same time with mod_rewrite in Apache.

    Jochem


    --
    Jochem van Dieten
    Adobe Community Expert for ColdFusion
    February 10, 2008
    Jochem,
    Thank you for the quick response.

    I had already tried to use the servlet mapping you suggested:
    <servlet-mapping>
    <servlet-name>CfmServlet</servlet-name>
    <url-pattern>/secureMe/*</url-pattern>
    </servlet-mapping>
    in the hopes that the OnRequestStart function would process the URL. However it seemed that Coldfusion would ignore the URL because it did not contain the *.cfm pattern.

    In your suggestion for the URL rewrite:
    "The use a utility like http://tuckey.org/urlrewrite/ to rewrite URLs from /secureMe/* to /secureMe/index.cfm/* and then in index.cfm put a cfcontent tag that sends the requested file."

    Did you mean rewrite the original URL from: /secureMe/private/files/foo.pdf (which is what I want to protect)
    to something like: /secureMe/index.cfm /private/files/foo.pdf ?
    or did you mean rewrite it to: /secureMe/index.cfm ?/private/files/foo.pdf
    so that the original URL is passed to the index.cfm as a QUERY_STRING argument?

    I am concerned that my OnRequestStart function is being bypassed when the URL is for non-cfm files and that using a UrlRewriteServlet to rewrite the URL and pass it to the index.cfm will not address the problem.

    If I must use a servlet to catch the incoming URLs for non-cfm files then I might as well scrap use of my OnRequestStart function (for cfm files) and simply use my own servlet to check user access for all incoming URLs.

    I was hoping that the Apache mod_jrun connector would be configurable to handle more than just file extensions. Ideally I would like to ability to configure the mod_jrun20 connector in Apache to handle the /secureMe/* pattern since it would be a cleaner solution.

    Thank you for your suggestions. They are appreciated and I will see if they work

    Steve Deal