Securing IIS and Web
Securing IIS and Web
Steps:
<configuration>
<system.web>
<!-- Disable detailed errors -->
<customErrors mode="On" defaultRedirect="~/Error.html">
<error statusCode="404" redirect="~/Errors/404.html" />
<error statusCode="500" redirect="~/Errors/500.html" />
</customErrors>
</system.web>
<system.webServer>
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath=""
path="/Errors/404.html" responseMode="ExecuteURL" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="500" prefixLanguageFilePath=""
path="/Errors/500.html" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>
Steps:
Steps:
Steps:
1. Open web.config.
2. Ensure the following settings are applied:
<system.web>
<customErrors mode="On" />
<compilation debug="false" />
</system.web>
Steps:
<location path="web.config">
<system.webServer>
<security>
<authorization>
<deny users="?" />
</authorization>
</security>
</system.webServer>
</location>
Steps:
1. Open web.config.
2. Add the following headers inside <system.webServer>:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-Content-Type-Options" value="nosniff" />
<add name="X-Frame-Options" value="SAMEORIGIN" />
<add name="X-XSS-Protection" value="1; mode=block" />
</customHeaders>
</httpProtocol>
</system.webServer>
Final Notes:
These configurations will enhance security by preventing detailed error messages and
restricting access to sensitive files.
Always test the settings in a staging environment before applying them to production.
Regularly review IIS and web.config settings to ensure compliance with security best
practices.