Forum Discussion

Wil_Schultz_101's avatar
Wil_Schultz_101
Icon for Nimbostratus rankNimbostratus
Feb 28, 2012

Need to change the HTTP Status code.

I have a maintenance page sitting on some servers, if all goes awry traffic is pointed at this page. I'd like to ba able to swap the status from HTTP 200 to HTTP 503. Can't seem to figure out a good way to do this using an iRule.

 

 

Is there a way other than using HTTP:collect and then HTTP:respond?

 

 

 

  • Hi Wil,

     

     

    I think HTTP::collect/HTTP::respond is the only practical option. I guess we could have a set option for HTTP::status, but the implications for that are a bit difficult to handle programmatically (ie, remove a payload of the new status is 304, Add a location header if it's a 30x?, etc).

     

     

    Aaron
  • Hrm, ran into some TCL variable size issues that I'd really like to never see again so I'm hesitant about using HTTP::collect right about now. 11.1 has some nice new features, also seems to have a few "undocumented features" as well.

     

     

    I'll come up with something. :-p
  • spark_86682's avatar
    spark_86682
    Historic F5 Account
    If I understand you correctly, you're trying to sometimes alter the HTTP status code of a response passing through the BIG-IP. You could just do this at the TCP level and bypass all of the messing about at the HTTP layer altogether. Something like (totally untested):

     

     

    
    when SERVER_CONNECTED {
       if { $should_alter_response_status } {
         TCP::collect 12
      }
    }
    when SERVER_DATA {
       set payload [TCP::payload 12]
       regsub 200 $payload 503 payload
       TCP::payload replace 0 12 $payload
       TCP::release
    }
     
  • Nice idea Spark. But you'd need to parse every response in TCP to check if you need to rewrite the response code. And it would get interesting trying to handle serverside connection reuse.

     

     

    Aaron
  • spark_86682's avatar
    spark_86682
    Historic F5 Account
    Well, the whole point of this approach would modify the data before the HTTP profile sees it, so you could still have an HTTP profile and have it do all the parsing. It does make the assumption that the HTTP server is well-behaved, though. Connection reuse does get interesting, but I think if you close the connection after doing a rewrite in this fashion that that will work.