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

Use request.remote_ip instead of request.ip to obtain buyer IP #1359

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

aminzam
Copy link
Contributor

@aminzam aminzam commented Jan 7, 2025

Description

This is a usage doc update to guide devs to accurately obtain the buyer IP using rail's request.remote_ip rather than request.ip. This is because the buyer can be behind a proxy server. The proxies usually set HTTP_CLIENT_IP and/or HTTP_X_FORWARDED_FOR headers to track the originating client IP. These headers are properly handled by request.remote_ip (doc). The developer can optionally introduce a set of known proxy servers to further control this behaviour by setting Rails.application.config.action_dispatch.trusted_proxies.

Checklist:

  • My commit message follow the pattern described in here
  • I have performed a self-review of my own code.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have updated the project documentation.
  • I have added a changelog line.

remote_ip is more accurate when dealing with proxies and load balancers.
This change improves the reliability of IP detection in our application.
@aminzam aminzam requested a review from a team as a code owner January 7, 2025 16:23
@aminzam aminzam merged commit feb5df0 into main Jan 7, 2025
9 checks passed
@aminzam aminzam deleted the use-remote-ip branch January 7, 2025 16:58
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

Successfully merging this pull request may close these issues.

2 participants