7 replies
October 2021

robertino.calcaterra Auth0 Employee

What’s up Devs! How did you like this post? Please share any comments or feedback with us on this thread :speaking_head:

1 reply
October 2021 ▶ robertino.calcaterra

Sam10

Can you explain the below line -
services.AddOcelot(Configuration);

What does Configuration mean this context. Is it an object or do we need to add any namespace for it

1 reply
October 2021

konrad.sopala

Tagging article author here @joydipkanjilal for visibility!

October 2021 ▶ Sam10

joydipkanjilal

The AddOcelot overloaded method adds ocelot services - in this example, we’re passing an instance of type IConfiguration (the instance name is Configuration) to the AddOcelot method as an argument. Hope this helps!

September 2023

StavoG

I have have been trying to implement IP Rate Limit on Ocelot with no success. The configuration below is not taking IP Address into account
“RateLimitOptions”: {
“ClientWhitelist”: [
],
“EnableRateLimiting”: true,
“Period”: “10s”,
“PeriodTimespan”: 1,
“Limit”: 1,
“HttpStatusCode”: 429
}

I tried this with a colleague, We both got rate limited even when we were not supposed to. We decided to log our IP address on the service behind the API Gateway (Ocelot), at least the service could pick up the different IP Addresses, maybe because we added this

“UpstreamHeaderTransform”: {
“X-Forwarded-For”: “{RemoteIpAddress}”
}

app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto });

So now we are thinking of applying rate limit on the service behind. Which is really not idea as it means we are not getting the full benefits of using Ocelot for our API GW.

Can you please advise where we might be getting things wrong

1 reply
September 2023 ▶ StavoG

StavoG

Hi, I take this back. I did some more digging and found where my issue was. I put the following under GlobalConfiguration, and it worked like a charm.

“RateLimitOptions”: {
“DisableRateLimitHeaders”: false,
“QuotaExceededMessage”: “Customize Tips!”,
“HttpStatusCode”: 429,
“ClientIdHeader”: “X-Forwarded-For”
}

Thanks a lot for your post

October 2023

andrea.chiarelli Auth0 Employee

Hi @StavoG,
Glad to hear that you solved your problem, and thank you so much for sharing the solution! :pray: