-
Notifications
You must be signed in to change notification settings - Fork 0
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
Reject non-standard HTTP methods at edge #103
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Description: - Previously non-standard/unimplemented HTTP requests such as `DEBUG` will pass through Fastly and hit the origin where nginx rejects them as 501. See [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/501) as to why this is the appropriate status code to return - Here Fastly is configured to throw a 501 and return custom HTML. The error code `806` and not `805` is used as the latter is used by `_security_txt_response.vcl` in the [shared VCL](https://github.com/alphagov/govuk-fastly/blob/main/modules/shared/_security_txt_response.vcl) - `FASTLYPURGE` is how the non-standard `PURGE` method appears in [VCL](https://www.fastly.com/documentation/reference/vcl/variables/client-request/req-method/) - Tested in integration and staging: ``` curl -w '\n%{http_code}\n' -X DEBUG https://www.staging.publishing.service.gov.uk <!DOCTYPE html> <html> <head> <title>Welcome to GOV.UK</title> <style> body { font-family: Arial, sans-serif; margin: 0; } header { background: black; } h1 { color: white; font-size: 29px; margin: 0 auto; padding: 10px; max-width: 990px; } p { color: black; margin: 30px auto; max-width: 990px; } </style> </head> <body> 501 ``` - See [proof of concept here](#78) with data to show that it won't block anything unintentionally - Closes #79
nimalank7
force-pushed
the
reject-nonstandard-HTTP-methods-edge
branch
from
August 30, 2024 15:22
5c01f63
to
72a03d0
Compare
theseanything
approved these changes
Aug 30, 2024
Comment on lines
+622
to
+638
synthetic {" | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Welcome to GOV.UK</title> | ||
<style> | ||
body { font-family: Arial, sans-serif; margin: 0; } | ||
header { background: black; } | ||
h1 { color: white; font-size: 29px; margin: 0 auto; padding: 10px; max-width: 990px; } | ||
p { color: black; margin: 30px auto; max-width: 990px; } | ||
</style> | ||
</head> | ||
<body> | ||
<header><h1>GOV.UK</h1></header> | ||
<p>We cannot find the page you're looking for. Please try searching on <a href="https://www.gov.uk/">GOV.UK</a>.</p> | ||
</body> | ||
</html>"}; |
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.
We probably could just return some text rather than HTML. Unlikely that a browser will send a non-standard HTTP method.
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.
True.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
DEBUG
will pass through Fastly and hit the origin where nginx rejects them as 501. See MDN documentation as to why this is the appropriate status code to return806
and not805
is used as the latter is used by_security_txt_response.vcl
in the shared VCLFASTLYPURGE
is how the non-standardPURGE
method appears in VCL