The issue we are trying to resolve is that if a backend webserver returns an internal server error (500) or otherwise, you might want to provide the end user with information he (or she) can send to the helpdesk. Especially Internet Explorer has convenient pages setup locally, that will not reveal anything on what might have gone wrong.
Returning an Oops! page when the backend webserver misfires.
An Oops page might look like this:
Oops!
(500 Internal Server Error)
Your IP address: 10.31.0.132
Requested url: www.mydomain.com/test123/
Please contact the helpdesk
How it is done:
- Create a policy expression called PE_SorryPage:
1add policy expression PE_SorryPage q{"HTTP/1.1 418 " + " " + HTTP.RES.STATUS_MSG + "\r\nContent-Type: text/html\r\n\r\n<HTML><BODY><H1>Oops!</H1><br><b>(" + HTTP.RES.STATUS + " " + HTTP.RES.STATUS_MSG + ") </b><br>Your IP address: " + client.IP.SRC + "<br>Requested url: " + HTTP.REQ.HOSTNAME + HTTP.REQ.URL + "<br> Please contact the helpdesk</BODY></HTML>"}
Notice: We actually give back 418 as error code (eat this IE) ;=) - Create a stringmap called SM_SorryHelper
1234567891011add policy stringmap SM_SorryHelperbind policy stringmap SM_SorryHelper 500 "Server Error"bind policy stringmap SM_SorryHelper 501 "Not implemented"bind policy stringmap SM_SorryHelper 405 "Method not allowed"bind policy stringmap SM_SorryHelper 400 "Bad Request"bind policy stringmap SM_SorryHelper 408 "Request Timeout"bind policy stringmap SM_SorryHelper 410 Gonebind policy stringmap SM_SorryHelper 505 "HTTP Version not supported"bind policy stringmap SM_SorryHelper 503 "Service Unavailable"bind policy stringmap SM_SorryHelper 403 Forbiddenbind policy stringmap SM_SorryHelper 404 "File or Directory Not Found"
Notice: The key values (like 500) are important in this stringmap, the values (like Server Error) are there as a reminder/remark.. (yes this could have been a patternset) - Create a rewrite action:
1add rewrite action RWA_SorryPage replace_http_res PE_SorryPage -bypassSafetyCheck YES - Create a rewrite policy:
1add rewrite policy RWP_ErrorPage "HTTP.RES.STATUS.TYPECAST_TEXT_T.IS_STRINGMAP_KEY(\"SM_SorryHelper\")" RWA_SorryPage - Bind the rewrite policy to the HTTP/HTTPS vserver.
Have fun!
Hi,
I applied same configuration to my NS. Even though rewrite policy is bound to both LBVS and CSVS, it cannot get any hits. I even tried to bind it globally but it doesn’t seem to work. I disable my HTTP services to get 503 response from NS.
What do you think of rewrite policies not getting hit even when I evaluate policy expression successfully? Where should I bind this rewrite policy and how should I test 503 response on NS.
Thanks,
Kind Regards.
Erdem Ulutas