aspnet / BasicMiddleware

[Archived] Basic middleware components for ASP.NET Core. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
169 stars 84 forks source link

Add Akamai True-Client-IP support #261

Closed h0useRus closed 5 years ago

h0useRus commented 7 years ago

Could you add Akamai True-Client-IP for ForwardedHeaders, or make it more modular for injecting custom headers handlers?

Tratcher commented 7 years ago

What's the format? It may be as easy as changing the default header name if the format matches: https://github.com/aspnet/BasicMiddleware/blob/347d1abfce8c257125bea17067f10cf30ce85396/src/Microsoft.AspNetCore.HttpOverrides/ForwardedHeadersOptions.cs#L16

h0useRus commented 7 years ago

Yes, we can, but then we loosing XForwardedFor header if Akamai header not exists and do extra configuration logic based on hosting environment.

Akamai sample here https://community.akamai.com/thread/4612-can-i-get-client-ip-from-this-header-httpcontextcurrentrequestheaderstrue-client-ip

Also is ForwarderdHeaders support IP v6? I'm not found any tests for it.

Tratcher commented 7 years ago

How about adding a separate instance of UseForwardedHeaders that specifies the Akamai header name? They can stack.

That thread doesn't show the contents of the header.

Yes, IPv6 is supported. https://github.com/aspnet/BasicMiddleware/blob/347d1abfce8c257125bea17067f10cf30ce85396/test/Microsoft.AspNetCore.HttpOverrides.Tests/IPEndPointParserTest.cs#L16-L18

h0useRus commented 7 years ago

Good point to know, it really solve the problem, not ideal, but works.

Here is official documentation from Akamai https://community.akamai.com/videos/1232

Got it, Great thanks.