F5 Maintenance Page iRule produces ERR_CONNECTION_RESET in browser

1.3k Views Asked by At

We have an F5 LTM that uses a simple iRule that puts up a maintenance page. It has worked fine for years - until we updated from to BigIP 15.1.5.1 (from 15.1.5.0). Now when we implement the iRule, the browser usually produces an ERR_CONNECTION_RESET error. By "usually" I mean if we refresh over and over, it will occasionally work.

The iRule is simple:

when HTTP_REQUEST {
   HTTP::respond 200 content \
    "<HTML><head><title>Maintenance Page</title></head><body>
     <p>This site is down for planned maintenance.
     <br>If you need further assistance, 
     please contact the Service Desk."</p>
     </body>
     </html>" "Content-Type" "text/html"
}

I did some research and found a couple of suggestions to try, but they have not helped. I believe it's something specific to the HTTP::respond content method.

This seems like a straightforward iRule. Are we missing something here?

Thank you in advance.

1

There are 1 best solutions below

0
On

I suppose you've figured it out by now but the problem was the quote in the middle of the string.

It failed because the iRule is only applied to new connections. Modern browsers try to re-use connections whereas command-line clients like curl makes a new one for each request. Try curl next time to test your iRules and you'll see a more consistent behavious.

Ps. With this in mind you might want to try the following:

  • Add 503 to give the clients the correct status code. Better for SEO purposes.
  • Add a retry-after header to signal when the maintenance is planned to be over.
  • Add connection close to make sure that the clients do not get the maintenance iRule when refreshing the page (ie. reusing the connection, look above).

Example maintenance iRule with the suggestions above:

when HTTP_REQUEST {
  HTTP::respond 503 content \
    "<HTML><head><title>Maintenance Page</title></head><body>
    <p>This site is down for planned maintenance.
    <br>If you need further assistance, 
    please contact the Service Desk.</p>
    </body>
    </html>" "Content-Type" "text/html" "Retry-After" "3600" "Connection" "Close"
}