-
Notifications
You must be signed in to change notification settings - Fork 93
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
feat: Add support for X-Sentry-forwarded-for header #2572
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is slightly worse that this is a proprietary header
Agree with this statement, but the code change LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code change looks good. I would just like this question addressed before moving ahead.
Alright I think we're going to move forward as was outlined by Anton in the JIRA ticket, implemented here https://github.com/getsentry/ops/pull/8175. @jan-auer sounds good to you? |
0d3b4df
to
c2a1d51
Compare
|
||
/// We prefer the Vercel header because the normal one could get overwritten as explained here. | ||
/// `https://vercel.com/docs/concepts/edge-network/headers#x-vercel-forwarded-for` | ||
fn get_forwarded_for_ip(header_map: &HeaderMap) -> &str { | ||
header_map | ||
.get(Self::VERCEL_FORWARDED_HEADER) | ||
.or_else(|| header_map.get(Self::SENTRY_FORWARDED_HEADER)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question came up if we should value our own header over the vercel header, the conclusion was:
- our infrastructure requires the "standard" x-forwarded-for to be trusted, so it puts the contents of just that header into the sentry version.
- at the same time, x-vercel-forwarded-for is the more accurate header overall if it is there. so it should be preferred over the other two.
Can you add an explanation to comment, so somebody in the future knows why the sentry header is not the highest priority (like there is already an explanation why the vercel header is preferred over the standard X-Forwarded-For header)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done with 3a97475
ref https://getsentry.atlassian.net/browse/OPS-3823
ref #2450
For users who use a SDK tunnel or proxy to route SDK events to Sentry, they often use the x-forwarded-for or x-vercel-forwarded-for to pass along the real client IP address to Sentry (so it can be stored with the Sentry event).
Current this doesn't work for SaaS Sentry because of restrictions we've placed on the infrastructure side.
This PR adds support for reading fromX-Sentry-Forwarded-For
header. It is slightly worse that this is a proprietary header, but it unblocks this for our customers without having to suffer the same challenges x-forwarded-for does.With https://github.com/getsentry/ops/pull/8175 we're making changes to the infra to map the value in
X-Forwarded-For
toX-Sentry-Forwarded-For
when the request gets forwarded from nginix to relay. This helps reduce the security concerns from blindly forwardingX-Forwarded-For
, and preserves existing usage ofX-Forwarded-For
. In addition, self-hosted and local relay usage can still useX-Forwarded-For
as usual.