• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 310
  • Last Modified:

Coldfusion Maintenance Page


I found this nifty tutorial  "Creating A "Down For Maintenance" Page Using Application.cfc", and using the cfc method referenced in the article it works great, but I need to be able to access the site from my IP address.

So my question is how would you  check for cgi.remote_addr ?

My thought was to check before the cffunction tag like this:


<cfif cgi.remote_addr NEQ 72.xxx.xxx.xxx>
      hint="Fires at the beginning of a page requested before the requested template is processed.">

      <!--- Define arguments. --->
            hint="The template that was requested by the user."

      <!--- Define the local scope. --->
      <cfset var LOCAL = StructNew() />

      <!--- Set header code. --->
            statustext="Service Temporarily Unavailable"

      <!--- Set retry time. --->

            Down For Maintenance

            The web site is current down for maintenance and will be back up shortly. Sorry for the inconvenience.

            By returning false, the rest of the page
            rendering will hault.
      <cfreturn false />


But that just throws error.   Can someone show me how to code this?

Thanks in advance!
  • 4
  • 3
1 Solution
Try putting the logic inside the function. Something like this

<cffunction ....>
    .... arguments here ....

     <!--- the ip is not allowed --> 
     <cfif cgi.remote_addr NEQ "72.xxx.xxx.xxx">
          ... down for maintenance headers/message

         <!--- abort processing --->
         <cfreturn false>
     <!--- if it's a valid ip, continue processing --->
     <cfreturn true>

Open in new window

Gurpreet Singh RandhawaWeb DeveloperCommented:
what error it throws down, can u elaborate on this
Bang-O-MaticAuthor Commented:
Works perfect! Thank you!
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Bang-O-MaticAuthor Commented:
Just as a follow up, this worked perfect on localhost, returning the html message.

when I ran it on production server it returns the correct http status code:

HTTP/1.1 503 Service Unavailable =>
Cache-Control => private
Content-Type => text/html
Retry-After => 3600
Vary => Accept-Encoding
Server => Microsoft-IIS/7.5
Set-Cookie => CFTOKEN=0; Expires=Fri, 10-Mar-2045 03:14:30 GMT; Path=/
X-AspNet-Version => 2.0.50727
X-Powered-By => ASP.NET
Date => Wed, 11 Mar 2015 19:23:00 GMT
Connection => close

but does not show the html "down for maint." text, it only shows "The service is unavailable"  Any ideas on this?  Only difference in setup is on localhost im running coldfusion 11 and on production server running railo4
Hm.. that sounds like it is displaying an IIS error message, rather than the custom text.

I am not near IIS/Railo at the moment.  Any change if you return a different status code temporarily? Try something other than 503.  

Just wondering if IIS is suppressing the custom message and displaying its own error handler instead.
Bang-O-MaticAuthor Commented:
thanks _agx_ the problem was that I didnt have a custom error page configured in IIS for status code 503.  Once I did that, it all works! Thanks again.
Ah, that makes sense.  Glad you figured it out.
Bang-O-MaticAuthor Commented:
I followed your advice and returned a 404 status code (i had a custom error page for 404) and that did display the "down for maint." html message. So thanks again _agx_!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now