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

add HTTP strict transport security header when force SSL is enabled #1855

Merged
merged 1 commit into from
Nov 17, 2020
Merged
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 omnibus/cookbooks/omnibus-supermarket/recipes/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

file 'environment-variables' do
path "#{node['supermarket']['var_directory']}/etc/env"
content Supermarket::Config.environment_variables_from(node['supermarket'])
content Supermarket::Config.environment_variables_from(node['supermarket'].merge('force_ssl' => node['supermarket']['nginx']['force_ssl']))
owner node['supermarket']['user']
group node['supermarket']['group']
mode '0600'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,13 @@
its('protocols') { should include 'tcp' }
end

describe "http GET to Port #{property['supermarket']['nginx']['ssl_port']}" do
subject { http("http://localhost:#{property['supermarket']['nginx']['ssl_port']}", ssl_verify: false) }
describe http("https://#{property['supermarket']['fqdn']}:#{property['supermarket']['nginx']['ssl_port']}", ssl_verify: false) do
it 'should not include server version number in response headers' do
expect(subject.headers.server).to cmp('nginx')
end

its('headers.keys') { should include('strict-transport-security') }
its('headers.Strict-Transport-Security') { should include('max-age=') }
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/supermarket/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
config.force_ssl = (ENV["FORCE_SSL"] == "true")

# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
Expand Down