Those useful and interesting technology snippets that I keep forgetting to write down until I need them again.
Thursday, 30 April 2015
Getting an IIS reverse proxy via ARR to use IIS custom error pages
This took a while to discover!
The problem - you have IIS configured with ARR and you have rewrite rules set up to pass incoming requests from IIS to a back office machine, e.g. Tomcat.
You would like to leverage IIS to display customer error pages when either IIS can't find a page, or the server behind the reverse proxy can't.
In the first case (404 coming from IIS directly) you can use the "Error Pages" feature of an IIS site (or the defaults set at the server level). Just double click the "Error Pages" feature and then in the Actions pane on the right, select "Edit Feature Settings". Pick "Custom error pages" get IIS to server up the files pointed to in the feature list for each status code.
You can then edit the file to or create a new file and point at it instead for a given error code.
However, by default, IIS assumes that if a request a reverse proxied then the remote server will handle setting the HTML for error scenarios, so if, e.g. 404 is returned from the reverse proxied server, IIS will display that response, and not interject with the custom page.
To change that behaviour, execute the following in an admin command prompt:
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/httpErrors -existingResponse:Replace
Hey presto, the reverse proxied reponse are now replaced as well.
I found this, after much searching here:
http://forums.iis.net/t/1157934.aspx?Web+farms+with+URL+rewrite+and+error+pages
Subscribe to:
Posts (Atom)