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

Add client IP #96

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add client IP #96

wants to merge 2 commits into from

Conversation

ZanyMonk
Copy link

@ZanyMonk ZanyMonk commented Mar 5, 2024

Add the client IP (http.Request.RemoteAddr) in the response "description".

@darklynx
Copy link
Owner

darklynx commented Mar 6, 2024

Hi @ZanyMonk

Thank you for your valuable contribution to the project.

I have no problem to merge your PR, however, I wanted to warn you about limited usefulness of this change: since Request Baskets service does not implement HTTPS protocol and certificates handling (on purpose, see #52), the recommended way to run the service is behind a proxy that support HTTPS, e.g. nginx. In this case the req.RemoteAddr will always point to the internal IP of the proxy and has a limited use for external users of the service.

You can get more insight and detailed explanation in this Stack Overflow answer: https://stackoverflow.com/a/27235620/2288384

Ideally the logic has to be extended and take into consideration the following HTTP request headers:

  • X-Forwarded-For - common header used by proxies and load balancers before a standard for Forwarded was estableshed
  • X-Real-Ip - another common HTTP headers, I have seen that its popular in nginx settings
  • Forwarded - a standard header, unfortunately not yet widely spread among classical proxies and load balancer, see Mozilla knowledge base article: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded

Would you prefer to extend your PR? Otherwise I can merge it AS IS.

Cheers,
darklynx

@darklynx darklynx mentioned this pull request Mar 6, 2024
@ZanyMonk
Copy link
Author

ZanyMonk commented Mar 6, 2024

Oh I didn't know about this issue.

Alright I'll come up with a better solution. Thank you for your quick and detailed answer.

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.

None yet

2 participants