Forum Discussion

saidshow_251381's avatar
saidshow_251381
Icon for Cirrostratus rankCirrostratus
Jun 06, 2016

Using an iRule to respond with a 500 Internal Server Error message

Hi,

 

We have a customer error page setup to serve a nice neat error page when various violations are triggered however the JSON applications don't like this as they are not expecting html. What I would like to do is implement an iRule based on any identifiable data such as a header, to respond with a 500 error. For the moment I am just working on the main idea of serving the 500 rather than the custom error however what I have is not working. If someone can review what I have below and let me know why this is ignored and the custom error continues to load, that would be awesome. Thank you.

 

when HTTP_RESPONSE {

 

if {[HTTP::header value Connection] contains "close"}{

 

HTTP::respond 500 content "Internal Server Error" }

 

}

 

9 Replies

  • Hi,

     

    Try to use Close instead of close

     

    Or

     

    Use

     

    if {[string tolower [HTTP::header value Connection]] contains "close"}{

     

    • saidshow_251381's avatar
      saidshow_251381
      Icon for Cirrostratus rankCirrostratus
      Hi Yann, thank you for the prompt reply. I have tried both of the suggestions however neither worked for me.
    • Yann_Desmarest's avatar
      Yann_Desmarest
      Icon for Cirrus rankCirrus
      Ok, that's there is no Connection:Close header, you need to use another header to identify errors. Maybe HTTP::status
  • Hi,

     

    Try to use Close instead of close

     

    Or

     

    Use

     

    if {[string tolower [HTTP::header value Connection]] contains "close"}{

     

    • saidshow_251381's avatar
      saidshow_251381
      Icon for Cirrostratus rankCirrostratus
      Hi Yann, thank you for the prompt reply. I have tried both of the suggestions however neither worked for me.
    • Yann_Desmarest_'s avatar
      Yann_Desmarest_
      Icon for Nacreous rankNacreous
      Ok, that's there is no Connection:Close header, you need to use another header to identify errors. Maybe HTTP::status
  • I am assuming the connection header is being sent by the client and not the server:

    when HTTP_REQUEST {
    if {[HTTP::header value Connection] contains "close"}{
    HTTP::respond 500 content "Internal Server Error" }
    }