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

Fastly: Include security headers for dl #7278

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion infra/fastly/terraform/dl-sandbox.k8s.dev/vcl/binaries.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ sub vcl_fetch {
}

# Ensure version markers are not cached at the edge
if (req.url.path ~ "^/release/(latest|stable)(-\d+(\.\d+))?\.txt\z") {
if (req.url.path ~ "^/release/(latest|stable)(-\d+(\.\d+)?)?\.txt\z") {
set beresp.cacheable = false;
set beresp.ttl = 0s;
return (pass);
Expand Down
13 changes: 12 additions & 1 deletion infra/fastly/terraform/dl.k8s.io/vcl/binaries.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ sub vcl_fetch {
}

# Ensure version markers are not cached at the edge
if (req.url.path ~ "^/release/(latest|stable)(-\d+(\.\d+))?\.txt\z") {
if (req.url.path ~ "^/release/(latest|stable)(-\d+(\.\d+)?)?\.txt\z") {
set beresp.cacheable = false;
set beresp.ttl = 0s;
return (pass);
Expand Down Expand Up @@ -109,6 +109,17 @@ sub vcl_hit {

sub vcl_deliver {

set resp.http.Content-Security-Policy = "default-src 'self'";
set resp.http.X-Frame-Options = "SAMEORIGIN";
set resp.http.X-XSS-Protection = "1";
set resp.http.X-Content-Type-Options = "nosniff";
set resp.http.Referrer-Policy = "origin-when-cross-origin";

if (req.protocol == "https") {
# Only connect to this site and subdomains via HTTPS for the next two years
set resp.http.Strict-Transport-Security = "max-age=63072000; includeSubDomains";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could add a comment about how we picked the max age.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sftim Done. PTAL

}

if (resp.http.cache-control:max-age) {
unset resp.http.expires;
}
Expand Down