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.
- 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
Package | Nuget |
---|---|
MBW.Http.AutoProxy | |
MBW.Http.AutoProxy.Cloudflare |
In your ConfigureService
, use the AddAutoProxyMiddleware()
helper, and then add in any sources you'd like to use, f.ex. Cloudflare
.
services.AddAutoProxyMiddleware()
In your app pipeline, in the Configure
method, add the middleware as soon as possible:
app.UseAutoProxyMiddleware();
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()
.
services.AddAutoProxyMiddleware()
.AddCloudflare()
.AddCloudflareUpdater();
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.