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 special case to get_real_ip_addr() for additional proxy #1433

Open
melange396 opened this issue May 11, 2024 · 0 comments
Open

Add special case to get_real_ip_addr() for additional proxy #1433

melange396 opened this issue May 11, 2024 · 0 comments
Labels
api change affect the API and its responses devops building, running, deploying, environment stuff, handy utils, repository-related, engineer QoL, etc logs and monitoring logging, monitoring, alerting

Comments

@melange396
Copy link
Collaborator

delphi.cmu.edu (128.2.25.162) is the hostname for our main website, but it also serves as a proxy to api.delphi.cmu.edu (aka api.covidcast.cmu.edu) for API requests. I believe this forwarding exists because the API server and the server for the website co-existed on the same machine in the past, and when their functionality was divided onto different hosts, we did not want to break old patterns used to access the API. Some client libraries and documentation still referred to the old hostname as recently as May 2023 (see #1164 ), and there are still some users who make API requests via that hostname.

This leads to some inaccuracy in the logs, as the "real" IP addresses of proxy users are not reported, but instead they all show up as "128.2.25.162". That also means that some proxy users could effectively DoS other proxy users due to the way we measure and enforce rate limiting (though users with API keys should be immune).

We can consider delphi.cmu.edu to be a trusted proxy in our chain... Add a special case to get_real_ip_addr() so that it uses "one level deeper" when the resulting IP would otherwise show up as "128.2.25.162". Some more explanation on this "depth" can be found here.

@melange396 melange396 added api change affect the API and its responses logs and monitoring logging, monitoring, alerting devops building, running, deploying, environment stuff, handy utils, repository-related, engineer QoL, etc labels May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api change affect the API and its responses devops building, running, deploying, environment stuff, handy utils, repository-related, engineer QoL, etc logs and monitoring logging, monitoring, alerting
Projects
None yet
Development

No branches or pull requests

1 participant