ski_junkie
ski_junkie

Reputation: 637

ASP.NET disable debug error messages on localhost

I have a project that is running a small node.js application as a reverse proxy. Some of the requests the reverse proxy receives are directed to IIS installed on the same machine, which naturally hit IIS over localhost / 127.0.0.1.

As a result, IIS automatically returns detailed error messages in the case of an error. Naturally, the proxy sends these to the user, which is not good because they contain more information than I want external users to see. I have tried to turn off the detailed error messages by explicitly setting compilation debug="false" in web.config, but since the requests come over the localhost, IIS seems determined to return detail debug error messages.

Is there a way to disable these debug error messages from being returned even when the request is coming over localhost?

I am running Windows 2012 RS, IIS 8, .NET 4.6.

Upvotes: 2

Views: 2472

Answers (1)

ski_junkie
ski_junkie

Reputation: 637

OK, I found what I needed to do to make sure that IIS never returns detailed error messages, local or not.

More details can be found here.

The short answer is: Launch IIS Manager, click on the website, under IIS go to Error Pages, right click on the pre-defined error message and select "Edit Feature Settings", and select "Custom error pages". Then define the page that you want displayed.

Alternatively, you can define your preferences in web.config under system.webServer with values such as those listed below. The "errorMode" defaults to "DetailedLocalOnly", which causes the issue I am trying to avoid. Setting to "Custom" resolves the issue.

<httpErrors errorMode="Custom">
    <remove statusCode="401" subStatusCode="-1"/>
    <error statusCode="401" prefixLanguageFilePath="" path="/errors/401.html" responseMode="ExecuteURL"/>
</httpErrors>

Upvotes: 1

Related Questions