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

Disable Varnish #42441

Merged
merged 1 commit into from Sep 21, 2021
Merged

Disable Varnish #42441

merged 1 commit into from Sep 21, 2021

Conversation

wjordan
Copy link
Contributor

@wjordan wjordan commented Sep 10, 2021

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 to true).

Caching behaviors can be handled entirely by CloudFront+Nginx,
so Varnish can be disabled.
Toggle Varnish with `node['cdo-varnish']['enabled']`.
Comment on lines +174 to +195
*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,
Copy link
Contributor Author

@wjordan wjordan Sep 10, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant