IISFrontGuard is an IIS HTTP Module providing comprehensive web application security including WAF functionality, rate limiting, geographic IP filtering, security event logging, automatic security header management, and webhook notifications for ASP.NET applications running on .NET Framework 4.8. Automatically removes server identification headers (X-Powered-By, Server) and adds essential security headers (CSP, HSTS, X-Frame-Options, etc.).
$ dotnet add package IISFrontGuard.ModuleIISFrontGuard is an enterprise-grade IIS HTTP Module that provides comprehensive web application security for ASP.NET applications running on .NET Framework 4.8. It integrates seamlessly with IIS to provide multiple layers of protection against common web threats.
Install-Package IISFrontGuard.Module
dotnet add package IISFrontGuard.Module
PM> Install-Package IISFrontGuard.ModuleNote: The package will automatically update your Web.config with required settings and open a getting started guide.
Execute the included SQL script to create the required database tables:
-- Located in: Content\Scripts\init.sqlThe package automatically configures your Web.config during installation with the following default settings. Please review and update as needed:
<configuration>
<connectionStrings>
<add name="IISFrontGuard"
connectionString="Data Source=.;Initial Catalog=IISFrontGuard;Integrated Security=True;TrustServerCertificate=True;" />
</connectionStrings>
<appSettings>
<!-- Database Configuration -->
<add key="GlobalLogger.DefaultConnectionStringName" value="IISFrontGuard" />
<add key="GlobalRequestEncryptionKey" value="YOUR-16-CHAR-KEY" />
<!-- Rate Limiting Configuration -->
<add key="RateLimitMaxRequestsPerMinute" value="150" />
<add key="RateLimitWindowSeconds" value="60" />
<!-- Trusted Proxy IPs (for X-Forwarded-For header validation) -->
<add key="TrustedProxyIPs" value="" />
<!-- Webhook Configuration (Optional) -->
<add key="Webhook.Enabled" value="false" />
<add key="Webhook.Url" value="" />
<add key="Webhook.AuthHeader" value="" />
<add key="Webhook.CustomHeaders" value="" />
<add key="Webhook.FailureLogPath" value="C:\Logs\webhook-failures.log" />
</appSettings>
<system.webServer>
<modules>
<add name="FrontGuardModule"
type="IISFrontGuard.Module.FrontGuardModule, IISFrontGuard.Module"
preCondition="managedHandler,runtimeVersionv4.0" />
</modules>
<!-- Remove unnecessary server headers for enhanced security -->
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By" />
</customHeaders>
</httpProtocol>
</system.webServer>
<system.web>
<!-- Remove ASP.NET version header -->
<httpRuntime enableVersionHeader="false" />
</system.web>
</configuration>The package includes a GeoLite2-Country database. To keep it updated:
UpdateGeoDb.bat script with your license keyAdd custom WAF rules to the database:
INSERT INTO WafRules (Name, Priority, IsEnabled, Action, Conditions)
VALUES ('Block SQL Injection', 100, 1, 'Block',
'[{"Field":"QueryString","Operator":"Contains","Value":"UNION SELECT"}]');Configure rate limits in Web.config:
<add key="RateLimitMaxRequestsPerMinute" value="150" />
<add key="RateLimitWindowSeconds" value="60" />Configure country blocking/allowing via database WAF rules:
INSERT INTO WafRules (Name, Priority, IsEnabled, Action, Conditions)
VALUES ('Block Specific Countries', 50, 1, 'Block',
'[{"Field":"Country","Operator":"Equals","Value":"CN,RU,KP"}]');To remove IISFrontGuard from your application:
Uninstall-Package IISFrontGuard.ModuleThe uninstall process will automatically:
Manual cleanup required:
For complete uninstallation instructions, see UNINSTALL_GUIDE.md included in the package.
For issues, questions, or contributions, please visit:
This project is licensed under the MIT License.
IISFrontGuard Team