Dusty
asked on
Coldfusion Maintenance Page
http://www.bennadel.com/blog/1118-creating-a-down-for-maintenance-page-using-application-cfc.htm
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>
<cffunction
name="OnRequestStart"
access="public"
returntype="boolean"
output="true"
hint="Fires at the beginning of a page requested before the requested template is processed.">
<!--- Define arguments. --->
<cfargument
name="TargetPage"
type="string"
required="true"
hint="The template that was requested by the user."
/>
<!--- Define the local scope. --->
<cfset var LOCAL = StructNew() />
<!--- Set header code. --->
<cfheader
statuscode="503"
statustext="Service Temporarily Unavailable"
/>
<!--- Set retry time. --->
<cfheader
name="retry-after"
value="3600"
/>
<h1>
Down For Maintenance
</h1>
<p>
The web site is current down for maintenance and will be back up shortly. Sorry for the inconvenience.
</p>
<!---
By returning false, the rest of the page
rendering will hault.
--->
<cfreturn false />
</cffunction>
</cfif>
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
But that just throws error. Can someone show me how to code this?
Thanks in advance!
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>
<cffunction
name="OnRequestStart"
access="public"
returntype="boolean"
output="true"
hint="Fires at the beginning of a page requested before the requested template is processed.">
<!--- Define arguments. --->
<cfargument
name="TargetPage"
type="string"
required="true"
hint="The template that was requested by the user."
/>
<!--- Define the local scope. --->
<cfset var LOCAL = StructNew() />
<!--- Set header code. --->
<cfheader
statuscode="503"
statustext="Service Temporarily Unavailable"
/>
<!--- Set retry time. --->
<cfheader
name="retry-after"
value="3600"
/>
<h1>
Down For Maintenance
</h1>
<p>
The web site is current down for maintenance and will be back up shortly. Sorry for the inconvenience.
</p>
<!---
By returning false, the rest of the page
rendering will hault.
--->
<cfreturn false />
</cffunction>
</cfif>
--------------------------
But that just throws error. Can someone show me how to code this?
Thanks in advance!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
what error it throws down, can u elaborate on this
ASKER
_agx_
Works perfect! Thank you!
Works perfect! Thank you!
ASKER
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
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
Edit:
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.
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.
ASKER
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.
ASKER
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_!