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
Disable Varnish #42441
Disable Varnish #42441
Conversation
Caching behaviors can be handled entirely by CloudFront+Nginx, so Varnish can be disabled. Toggle Varnish with `node['cdo-varnish']['enabled']`.
5f97664
to
9862ee9
Compare
*HTTP_CACHE.keys.map do |app_name| | ||
proxy = (app == :hourofcode) ? :pegasus : app | ||
{ | ||
Id: app_name == proxy ? 'cdo' : app_name, | ||
CustomOriginConfig: { | ||
OriginProtocolPolicy: 'match-viewer', | ||
OriginSSLProtocols: %w(TLSv1.2 TLSv1.1) | ||
}, | ||
DomainName: origin, | ||
OriginPath: '', | ||
OriginShield: { | ||
Enabled: true, | ||
OriginShieldRegion: {Ref: 'AWS::Region'} | ||
}, | ||
OriginCustomHeaders: app_name == proxy ? [] : [ | ||
{ | ||
HeaderName: 'X-Cdo-Backend', | ||
HeaderValue: app_name | ||
} | ||
] | ||
} | ||
}, | ||
end, |
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.
This is creating an extra 'Origin' in addition to 'cdo'
, which the distribution can use as a proxy
target (so the pegasus/hourofcode distributions will have an extra dashboard
origin, and dashboard will have an extra pegasus
origin). The only difference in the second origin is that it sets a custom HTTP request header X-Cdo-Backend
to pegasus
/dashboard
, which nginx then uses as an override when selecting the proper backend app.
This implements the 'proxy'
http-cache-config behavior outside of Varnish.
This PR implements caching/routing behaviors entirely in CloudFront+Nginx so Varnish can be disabled and removed from the HTTP stack.
Toggle Varnish on/off with
node['cdo-varnish']['enabled']
(currently default totrue
).