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

Addresses #10 - jfryman/nginx has become voxpupuli/puppet-nginx #11

Open
wants to merge 2 commits into
base: master
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
3 changes: 3 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
'jfryman/nginx': {
class{'nginx_hardening::jfryman': }
}
'voxpupuli/nginx': {
class{'nginx_hardening::voxpupuli': }
}
'none': {
fail('You haven\'t configured a Nginx provider for hardening.')
}
Expand Down
71 changes: 71 additions & 0 deletions manifests/voxpupuli.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# === Copyright
#
# Copyright 2014, Deutsche Telekom AG
# Licensed under the Apache License, Version 2.0 (the "License");
# http://www.apache.org/licenses/LICENSE-2.0
#

# == Class: nginx_hardening::voxpupuli
#
# Overlay provider for voxpupuli/nginx
#
# === Parameters
#
# none
#
class nginx_hardening::voxpupuli(
$conf_dir = $nginx::conf_dir,
$package_source = $nginx::package_source
) {
# try to configure advanced options, if possible
if $package_source != 'nginx' and $package_source != 'passenger' {
# install required package
package { 'nginx-extras':
ensure => installed,
alias => 'nginx-extras'
}

# configure options
$more_clear_headers = [
'\'Server\'',
'\'X-Powered-By\''
]
} else {
$more_clear_headers = []
}

# finally we need to make sure our options are written to the config file
class{'nginx_hardening::voxpupuli_override': }

# additional configuration

$client_header_buffer_size = '1k'

$large_client_header_buffers = '2 1k'

$client_body_timeout = '10'

$client_header_timeout = '10'

$send_timeout = '10'

$limit_conn_zone = '$binary_remote_addr zone=default:10m'
$limit_conn = 'default 5'

$add_headers = [
# vvoid clickjacking
'X-Frame-Options SAMEORIGIN',

# disable content-type sniffing
'X-Content-Type-Options nosniff',

# XSS filter
'X-XSS-Protection "1; mode=block"'
]

# addhardening parameters
file { "${::nginx::config::conf_dir}/conf.d/90.hardening.conf":
ensure => file,
content => template('nginx_hardening/hardening.conf.erb'),
}
}
31 changes: 31 additions & 0 deletions manifests/voxpupuli_override.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# === Copyright
#
# Copyright 2014, Deutsche Telekom AG
# Licensed under the Apache License, Version 2.0 (the "License");
# http://www.apache.org/licenses/LICENSE-2.0
#

# == Class: nginx_hardening::voxpupuli_override
#
# Overlay provider for voxpupuli/nginx
#
# === Parameters
#
# none
#
class nginx_hardening::voxpupuli_override inherits ::nginx::config {

$server_tokens = 'off'

$keepalive_timeout = '5 5'

$client_body_buffer_size = '1k'

$client_max_body_size = '1k'

File["${::nginx::conf_dir}/nginx.conf"]{
content => template($::nginx::conf_template),
mode => '0600',
}

}
6 changes: 1 addition & 5 deletions templates/hardening.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ client_header_buffer_size <%= @client_header_buffer_size %>;

large_client_header_buffers <%= @large_client_header_buffers %>;

client_body_timeout <%= @client_body_timeout %>;

client_header_timeout <%= @client_header_timeout %>;

send_timeout <%= @send_timeout %>;

limit_conn_zone <%= @limit_conn_zone %>;
limit_conn <%= @limit_conn %>;

<% Array(@add_headers).each do |x| %>
add_header <%= x %>;
<% end %>
<% end %>