Forum Discussion

reseob_90588's avatar
reseob_90588
Icon for Nimbostratus rankNimbostratus
Jul 25, 2013

Adding properly formatted headers to maintenance messages

Hey Guys,

 

I've spent a bit of time trying to figure out how to build an i-Rule that will respond in a manner that we would like. The gist of it is that we would like to add the retry-after (set to 10800) and set the connection to close.

 

I've read through a handful of articles, including https://devcentral.f5.com/community/group/aft/2163373/asg/50, which discusses a similar concept. I've attempted every option they've discussed there with no positive results.

 

 

Here's the gist of our i-Rule (note, there's a section I've not copied in which is basically the creation of a variable called maintenance_msg, which is just the HTML for the page).

 

Original i-Rule:

 

when HTTP_REQUEST {

 

if {[active_members [LB::server pool]] == 0 || [HTTP::uri] == "/maintenance.htm"}{

 

if {$::debug}{log local0. "Displaying maintence page."}

 

HTTP::respond 503 content $::maintenance_msg

 

 

}

 

}

 

 

Attempted to modify it and add the Retry-After: 10800 (also Retry-After 10800). Results showed no difference in the header, and the page still worked just fine.

 

 

when HTTP_REQUEST {

 

if {[active_members [LB::server pool]] == 0 || [HTTP::uri] == "/maintenance.htm"}{

 

if {$::debug}{log local0. "Displaying maintence page."}

 

HTTP::respond 503 Retry-After: 10800 content $::maintenance_msg

 

 

}

 

}

 

 

I attempted to add HTTP::header replace Retry-After 10800 as a separate line pre and post the HTTP::respond. Post responded as above, while pre broke the web page.

 

 

The very end of that link above discusses having an HTTP_REQUEST_SEND, SERVER_DATA, and HTTP_RESPONSE. This gave the same results as above where the page broke.

 

When the page broke, I loaded up Fiddler to see what was going on (which is also what I was using to view the response header). I ended up getting this error:

 

"The server did not return properly formatted HTTP Headers. HTTP headers should be terminated with CRLFCRLF. These were terminated with LFLF."

 

 

Based on this, I need to add some carriage returns to my header, but I'm not certain how to do that. Also, I expect that once I get the Retry-After function to work, simply adding the Connection function will work in an identical manner, so I've not tinkered with it yet.

 

 

Thanks!

 

 

2 Replies

  • A few tings to consider:

    1. First, Headers are inserted AFTER content in the HTTP::respond command:

    
    when HTTP_REQUEST {
    if { ( [active_members [LB::server pool]] == 0 ) or ( [HTTP::uri] equals "/maintenance.htm" ) } {
    HTTP::respond 503 content "blah" "Retry-After" 5 "Connection" "Close"
    }
    }
    

    2. The Retry-After header value is in seconds, so 10800 is 3 hours.

    3. I don't know of ANY browser that pays attention to this header. I've read that some web spiders do (ex. Googlebot), but that's about it.

    4. If this is for browser-based traffic, I'd probably recommend something like a meta-refresh header in the maintenance page that redirected back to the site. You could even dynamically fill the refresh header with the last URI requested.

  • Thanks for your response!

     

     

    I wasn't aware of the header locations, so thank you for that information. I was aware of the retry after value, and this is the number our web admins requested. I will recommend the other options to them and see if they'd like another tool for the retries.