Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the real User's desktop IP vs proxy ip address #475

Open
tahayazdani opened this issue Dec 8, 2023 · 0 comments
Open

Get the real User's desktop IP vs proxy ip address #475

tahayazdani opened this issue Dec 8, 2023 · 0 comments

Comments

@tahayazdani
Copy link

Hi,
it might been already asked by someone here, but asking this anyways as I'm facing this issue on my end.

so, I have a web server/app server application as following and want to get the real user's IP address

Step1: User desktop send a request to the web application(web server) which is on our firewall.
Step2: the web server calls some services in app server (micro service) where I have implemented my rate limit which is also on our firewall

so, I have tried both "X-Real-IP" and "X-Forwarded-For" but still capturing the same firewall IP address which is wrong

btw, I am on .Net 6 and here is my code

services.AddSingleton(rateLimitingConfig);
services.Configure(options =>
{
options.EnableEndpointRateLimiting = true;
options.StackBlockedRequests = false;
options.DisableRateLimitHeaders = true;
options.HttpStatusCode = 429;
options.RealIpHeader = "X-Real-IP"; // this is supposed to get the ip behind proxy based on the link above
options.ClientIdHeader = "X-ClientId";
options.GeneralRules = new List
{
new RateLimitRule
{
Endpoint = rateLimitingConfig.Endpoint,
Period = rateLimitingConfig.Period,
Limit = rateLimitingConfig.Limit,
}
};
});
services.AddSingleton<IIpPolicyStore, MemoryCacheIpPolicyStore>();
services.AddSingleton<IRateLimitCounterStore, MemoryCacheRateLimitCounterStore>();
services.AddSingleton<IRateLimitConfiguration, RateLimitConfiguration>();
services.AddSingleton<IProcessingStrategy, AsyncKeyLockProcessingStrategy>();
services.AddInMemoryRateLimiting();
services.AddSingleton<IIpPolicyStore, DistributedCacheIpPolicyStore>();
services.AddSingleton<IRateLimitCounterStore, DistributedCacheRateLimitCounterStore>();

builder.UseIpRateLimiting();

any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant