-
Notifications
You must be signed in to change notification settings - Fork 9
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: improve traffic filtering at nginx #1359
Conversation
6642af0
to
a1586a2
Compare
08dc906
to
ae926aa
Compare
👀 Finished code reviewing this. Still need to do manual testing
|
Sorry I realized that there was a bug in one of the regexes, it wouldn't have matched Then I also wanted to clarify in the tests that the 404 actually does come from nginx and not Django. |
🤔 for the rate limit (just like the 404) we shouldn't be seeing a Benefits error page. The rate limit happens before the request gets to Django, and returns a 503. It should be an nginx error page? |
I'm going to rebase on |
cal-itp/docker-python-web defines the default nginx.conf take a copy so we can override for benefits
based on data from amplitude and sentry
settings was removed from the session module with rate-limit refactor this test shouldn't use the session module anyway, as it is testing a middleware
POST to /eligibility/confirm needs to respect rate limit
checking for extension only
144c206
to
1f33670
Compare
Oh hmm. So I should be seeing an nginx error page for both the 404 and 503? I was seeing Benefits error pages. |
Exactly. See the modification to the I'm going to modify the |
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.
I ran into some issues while trying out the Cypress tests. I don't think they necessarily point out problems with the actual code refactor, but rather are bugs in the tests / local environment issues.
OK this is the runtime I expected to see: https://github.com/cal-itp/benefits/actions/runs/4736775820/jobs/8408740937 |
otherwise these are undefined in the tests that need them
4d73639
to
a1a3c43
Compare
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.
Ran through the tests again on rebased commits. Looks good!
As part of reducing the unnecessary traffic we send to Sentry (see Slack thread for more context) and Amplitude (see e.g. #1285 for some prior work), this PR adds filtering at the
nginx
layer - before traffic even hits the Django app where Sentry, Amplitude, etc. come into play.Based on a quick analysis of both Amplitude and Sentry, immediately 404 known scraping targets like
*.php
and/api/whatever
.I also took the opportunity to close #502 by moving rate limiting into
nginx
.Notes for reviewers
nginx
, the devcontainer uses a local dev servercypress
tests for the scraper targets, or trigger 404 manually in the browser/eligibility/confirm
, thecypress
tests have been updated