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

Wrong Remote Ip Address depends on configuration #231

Closed Tratcher closed 7 years ago

Tratcher commented 7 years ago

From @jkljajic on May 1, 2017 9:22

nginx_windows10 Same configuration only diffrence is OS and IIS version. i think picture telling all story. i would like to know how to catch good IP on windows server 2012 not gateway nginx ip address. and i hope this is good place to post this issue ?

Copied from original issue: aspnet/KestrelHttpServer#1801

Tratcher commented 7 years ago

Please move this to BasicMiddleware. What settings do you have for ForwardedHeaderOptions?

Tratcher commented 7 years ago

From @jkljajic on May 1, 2017 10:39

IS same for all 3 configuration

var forwardedOptions = new ForwardedHeadersOptions
            {
                RequireHeaderSymmetry = false,
                ForwardedHeaders = ForwardedHeaders.All,
                KnownNetworks =
                {
                    new IPNetwork(IPAddress.Parse("103.21.244.0"), 22),
                    new IPNetwork(IPAddress.Parse("103.22.200.0"), 22),
                    new IPNetwork(IPAddress.Parse("103.31.4.0"), 22),
                    new IPNetwork(IPAddress.Parse("104.16.0.0"), 12),
                    new IPNetwork(IPAddress.Parse("108.162.192.0"), 18),
                    new IPNetwork(IPAddress.Parse("131.0.72.0"), 22),
                    new IPNetwork(IPAddress.Parse("141.101.64.0"), 18),
                    new IPNetwork(IPAddress.Parse("162.158.0.0"), 15),
                    new IPNetwork(IPAddress.Parse("172.64.0.0"), 13),
                    new IPNetwork(IPAddress.Parse("173.245.48.0"), 20),
                    new IPNetwork(IPAddress.Parse("188.114.96.0"), 20),
                    new IPNetwork(IPAddress.Parse("190.93.240.0"), 20),
                    new IPNetwork(IPAddress.Parse("197.234.240.0"), 22),
                    new IPNetwork(IPAddress.Parse("198.41.128.0"), 17),
                    new IPNetwork(IPAddress.Parse("199.27.128.0"), 21),
                    new IPNetwork(IPAddress.Parse("10.10.20.0"), 24),
                    new IPNetwork(IPAddress.Parse("2400:cb00::"), 32),
                    new IPNetwork(IPAddress.Parse("2405:8100::"), 32),
                    new IPNetwork(IPAddress.Parse("2405:b500::"), 32),
                    new IPNetwork(IPAddress.Parse("2606:4700::"), 32),
                    new IPNetwork(IPAddress.Parse("2803:f800::"), 32),
                    new IPNetwork(IPAddress.Parse("2c0f:f248::"), 32),
                    new IPNetwork(IPAddress.Parse("2a06:98c0::"), 29)
                }
            };
muratg commented 7 years ago

@jkljajic were you able to figure out what the issue was?

jkljajic commented 7 years ago

@muratg sorry i just give up and use X-Real-IP from Nginx and do not use internal get IP method

muratg commented 7 years ago

Thanks @jkljajic