stefanprodan / AspNetCoreRateLimit

ASP.NET Core rate limiting middleware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RateLimiting Not Working

DhanushAdla opened this issue · comments

I have followed as below but not able to figure out the issue.

builder.Services.AddMemoryCache();
builder.Services.Configure(options =>
{
options.GeneralRules = new List
{
new RateLimitRule
{
Endpoint="/eTest-service/eTest/*",
Limit=2,
Period="1m",
}
};
});

builder.Services.AddSingleton<IRateLimitCounterStore, MemoryCacheRateLimitCounterStore>();
builder.Services.AddSingleton<IIpPolicyStore, MemoryCacheIpPolicyStore>();
//builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
builder.Services.AddSingleton<IRateLimitConfiguration, RateLimitConfiguration>();
builder.Services.AddSingleton<IProcessingStrategy, AsyncKeyLockProcessingStrategy>();

app.UseIpRateLimiting();

I have endpoints as https://testing.com/eTest-service/eTest/method1 or method2 and so on...

Also health check as https://testing.com/health

I dont want to include rate limiting for health check when I add endpoint as * eveything is limited and when I add as /eTest-service/eTest/* it allows n number of times, basically limiting not working.

Could you please help on this.

Can someone please help on this!!