BBelius.Yarp.ReverseProxy.IPFilters 1.2.0

dotnet add package BBelius.Yarp.ReverseProxy.IPFilters --version 1.2.0
NuGet\Install-Package BBelius.Yarp.ReverseProxy.IPFilters -Version 1.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BBelius.Yarp.ReverseProxy.IPFilters" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BBelius.Yarp.ReverseProxy.IPFilters --version 1.2.0
#r "nuget: BBelius.Yarp.ReverseProxy.IPFilters, 1.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BBelius.Yarp.ReverseProxy.IPFilters as a Cake Addin
#addin nuget:?package=BBelius.Yarp.ReverseProxy.IPFilters&version=1.2.0

// Install BBelius.Yarp.ReverseProxy.IPFilters as a Cake Tool
#tool nuget:?package=BBelius.Yarp.ReverseProxy.IPFilters&version=1.2.0

YARP IP Filter Middleware

A customizable IP filtering middleware for Microsoft's YARP (Yet Another Reverse Proxy) that provides fine-grained control over allowed or blocked IP addresses globally and per-route, ensuring secure and flexible access management.


  • Global IP filtering policies
  • Route-specific IP filtering policies
  • Easy integration with YARP
  • Blocklist and allowlist support
  • Can dynamically reload configuration changes


Install the package via NuGet:

dotnet add package BBelius.Yarp.ReverseProxy.IPFilters


  1. Add the IP filter policy provider service to the DI services bootstrapping code:
using BBelius.Yarp.ReverseProxy.IPFilters;
  1. Add the IP filter middleware to the YARP middleware pipeline:
// Register the reverse proxy routes
app.MapReverseProxy(proxyPipeline =>

Recommendation: Add it before any other YARP middleware. Important: Do not add the middleware to the regular ASP.NET Core pipeline, as it requires access to the YARP HttpContext object. More information about the YARP middleware pipeline can be found here.

  1. Configure the IP filter policy provider in your appsettings.json:
  "IPFilterConfiguration": {
    "EnableGlobalPolicy": true, // Defaults to false
    "GlobalPolicyName": "Global", // Optional, defaults to "Global"
    "Policies": [
      // Block remote IPs matching the list
        "PolicyName": "Global",
        "Mode": "BlockList",
        "IPAddresses": ["", ""]
      // Block remote IPs not within the networks
        "PolicyName": "Intranet", 
        "Mode": "AllowList",
        "IPNetworks": [""]
        "PolicyName": "TestPolicy",
        "Mode": "Disabled",
        "IPAddresses": ["", ""],
        "IPNetworks": [""]

You can use both, IPNetworks and IPAddresses in a policy. If at least one mathces the filter will be applied.

  1. Configure the YARP routes to use the policies:
  "ReverseProxy": {
    "Routes": [
        "RouteId": "route1",
        "ClusterId": "cluster1",
        "Match": {
          "Path": "/{**catch-all}"
        "Metadata": {
          "IPFilterPolicy": "Intranet"


This project is licensed under the MIT License - see the LICENSE file for details.


Contributions are welcome! Please open an issue or submit a pull request.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.0 474 11/17/2023
1.1.1 654 4/22/2023
1.1.0 124 4/21/2023
1.0.3 137 4/18/2023

### Added
- .Net 8 as target framework
### Fixed
- Ambiguous use of `IPNetwork` when targeting .Net 8