Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lordmike/mbw.http.autoproxy
A utility to ease configuration of proxy middlewares in ASP.Net
https://github.com/lordmike/mbw.http.autoproxy
asp-net
Last synced: about 11 hours ago
JSON representation
A utility to ease configuration of proxy middlewares in ASP.Net
- Host: GitHub
- URL: https://github.com/lordmike/mbw.http.autoproxy
- Owner: LordMike
- License: mit
- Created: 2018-09-05T19:00:34.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-09-19T21:14:54.000Z (about 1 year ago)
- Last Synced: 2024-10-05T21:16:39.995Z (about 1 month ago)
- Topics: asp-net
- Language: C#
- Homepage:
- Size: 57.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# MBW.Http.AutoProxy [![Generic Build](https://github.com/LordMike/MBW.Http.AutoProxy/actions/workflows/dotnet.yml/badge.svg)](https://github.com/LordMike/MBW.Http.AutoProxy/actions/workflows/dotnet.yml) [![Nuget](https://img.shields.io/nuget/v/MBW.Http.AutoProxy)](https://www.nuget.org/packages/MBW.Http.AutoProxy)
A utility to ease configuration of proxy middlewares in ASP.Net, to read in `X-Forward-For` and `X-Forwarded-Proto` from one or more trusted proxies.
### Features
* One-method add of proxies, with no additional configuration
* Possible to add in own sources for trusted proxies
* Known proxy lists, f.ex. Cloudflare
* Ability to auto-update proxy lists, should they change### Packages
| Package | Nuget |
| ------------- |:-------------:|
| MBW.Http.AutoProxy | [![NuGet](https://img.shields.io/nuget/v/MBW.Http.AutoProxy.svg)](https://www.nuget.org/packages/MBW.Http.AutoProxy) |
| MBW.Http.AutoProxy.Cloudflare | [![NuGet](https://img.shields.io/nuget/v/MBW.Http.AutoProxy.Cloudflare.svg)](https://www.nuget.org/packages/MBW.Http.AutoProxy.Cloudflare) |### Usage
In your `ConfigureService`, use the `AddAutoProxyMiddleware()` helper, and then add in any sources you'd like to use, f.ex. `Cloudflare`.
```csharp
services.AddAutoProxyMiddleware()
```In your app pipeline, in the `Configure` method, add the middleware as soon as possible:
```csharp
app.UseAutoProxyMiddleware();
```#### Add Cloudflare
To add in the initial configuration (a hardcoded set of IP's that will update with the nuget packages), use `AddCloudflare()`. To get the auto-updater that will query the Cloudflare ip lists once every while, use `AddCloudflareUpdater()`.
```csharp
services.AddAutoProxyMiddleware()
.AddCloudflare()
.AddCloudflareUpdater();
```#### Extend with extra sources
Take a look at the `AutoProxyExtensions` class in the Cloudflare package, it shows how to call into the `IAutoProxyConfigurator` service and add information. In short, you need to call `IAutoProxyConfigurator.AddInitialRanges()` to add an initial, hard-coded, configuration, and then `IAutoProxyStore.ReplaceRanges()` when you have an update.