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
Getting Source IP Behind Proxy #21582
Comments
@Tratcher any ideas? |
What version of AspNetCore is this? We've made a few fixes around Check these troubleshooting steps and share the request headers before UseForwardedHeaders. |
@Tratcher I'm currently running .Net Core 3.1.1 With logging enabled:
I also see I forgot to preface, everything is also running behind Cloudflare as well. |
With the logging enabled, I could see my real IP was in the I modified my SignalR getIp() method as follows:
This now allows me to get the proper IP from cloudflare. I should be able to also modify my HAProxy configuration to set the default EDIT:
|
FYI d36dcca added mitigations for Oh I see the issue, you're defining ForwardedHeadersOptions twice, once in ConfigureServices and once in Configure. These don't stack, the later options are the ones used and they don't have KnownNetworks set. Change Configure to this: |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate. See our Issue Management Policies for more information. |
From @SonoranBrian on Thursday, May 7, 2020 12:17:38 AM
I have a .Net Core application running in a docker container as my backend service. Clients connect to the backend through HAProxy -> Kestrel -> .Net Core Service
I'm trying to capture the user's IP address, but am unable to get the true client IP.
startup.cs
Getting the client IP (Signalr)
The IP address captured is
::ffff:XXX.XX.X.X
(The X representing our HA Proxy server, not the client IP)I've also tried manually setting the HAProxy forwarded IP to 1.1.1.1:
http-request set-header X-Forwarded-For 1.1.1.1
but this still shows as the HAProxy's internal IP and not the forced 1.1.1.1.In HAProxy if I try to enable
send-proxy
I receive the following error:Any help is greatly appreciated!
Copied from original issue: SignalR/SignalR#4470
The text was updated successfully, but these errors were encountered: