Git Product home page Git Product logo

chef-nginx-hardening's Introduction

nginx-hardening (Chef cookbook)

Supermarket Build Status Code Coverage Dependencies Gitter Chat

Description

This cookbook provides a secure overlay for nginx configuration.

Requirements

  • Chef 12+

Platform

  • Debian 7, 8
  • Ubuntu 14.04, 16.04
  • CentOS 6, 7
  • OracleLinux 6.6, 6.7, 7.1

Attributes

  • ['nginx']['client_body_buffer_size'] - 1k Sets buffer size for reading client request body. In case the request body is larger than the buffer, the whole body or only its part is written to a temporary file.
  • ['nginx']['default_site_enabled'] - false to disable the default site. Set to on to enable the default site in nginx.
  • ['nginx']['client_max_body_size'] - 1k to set the maximum allowed size of the client request body, specified in the "Content-Length" request header field. If the size in a request exceeds the configured value, the 413 (Request Entity Too Large) error is returned to the client.
  • ['nginx']['keepalive_timeout'] - 5 5 The first parameter sets a timeout during which a keep-alive client connection will stay open on the server side. The zero value disables keep-alive client connections. The optional second parameter sets a value in the "Keep-Alive: timeout=time" response header field.
  • ['nginx']['server_tokens'] - off to disable disables emitting nginx version in error messages and in the "Server" response header field. Set to on to enable the nginx version in error messages and "Server" response header.
  • ['nginx-hardening']['source']['http_autoindex_module'] - false to disable the HTTP Autoindex module. Set to true to enable http_autoindex_module.
  • ['nginx-hardening']['source']['http_ssi_module'] - false to disable the HTTP SSI module. Set to true to enable http_ssi_module.
  • ['nginx-hardening']['options']['ssl_protocols'] - 'TLSv1.2' to specify the SSL protocol which should be used.
  • ['nginx-hardening']['options']['ssl_ciphers'] - 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256' to specify the TLS ciphers which should be used.
  • ['nginx-hardening']['options']['ssl_prefer_server_ciphers'] - 'on' Specifies that server ciphers should be preferred over client ciphers when using the TLS protocols. Set to false to disable it.
  • ['nginx-hardening']['dh-size'] - 2048 Specifies the length of DH parameters for EDH ciphers.

You can also use the complete attributes from the nginx cookbook

Usage

Add the recipes to the run_list:

"recipe[apt]"
"recipe[nginx-hardening::upgrades]"
"recipe[nginx]"
"recipe[nginx-hardening]"

Configure attributes:

"nginx-hardening" : {
  "dh-size" : "4096"
}

Local Testing

For local testing you can use vagrant or docker to run tests locally. You will have to install VirtualBox and Vagrant or docker on your system. See Vagrant Downloads for a vagrant or Docker Downloads package suitable for your system. For all our tests we use test-kitchen. If you are not familiar with test-kitchen please have a look at their guide.

# Install dependencies
gem install bundler
bundle install

# Do lint checks
bundle exec rake lint

# fast test on one machine
bundle exec kitchen test default-ubuntu-1404

# test on all machines
bundle exec kitchen test

# for development
bundle exec kitchen create default-ubuntu-1404
bundle exec kitchen converge default-ubuntu-1404
bundle exec kitchen verify default-ubuntu-1404

Contributors + Kudos

Contributing

See contributor guideline.

License and Author

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

chef-nginx-hardening's People

Contributors

arlimus avatar artem-sidorenko avatar atomic111 avatar chris-rock avatar ehaselwanter avatar enzor avatar mburns avatar onwsk8r avatar renovate[bot] avatar rockstar04 avatar rveznaver avatar schurzi avatar tas50 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chef-nginx-hardening's Issues

release version

Hey, it would be really nice to have a release version that i can reference in Berks, it can even be 0.x.x. Anything I can do to help?

Cheers
Jannis

Is this cookbook maintained ?

Since the 31h of May, 2019, the sous-chef team completely broke the nginx cookbook since they have deleted the recipies folder ...

Then this cookbook, which depends on the nginx one, seem no more usable since the usage shows nginx default recipe in the run list.

So are you maintaining this cookbook, and therefore will you update it in a way that the final nginx installation is secured or shall this repo be archived ?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

bundler
Gemfile
  • berkshelf '~> 8.0'
  • chef '~> 18'
  • chefspec '~> 9.3.0'
  • foodcritic '~> 16.0'
  • cookstyle '~> 7'
  • minitest '~> 5.23.0'
  • simplecov '~> 0.10'
  • guard-foodcritic '~> 3.0'
  • test-kitchen '~> 3.6.0'
  • concurrent-ruby '~> 1.3.0'
  • github_changelog_generator '~> 1.14'
github-actions
.github/workflows/codespell.yml

  • Check this box to trigger a request for Renovate to run again on this repository

nginx returns 503 responses for requests

I experienced a lot of 503 responses if nginx is used with hardening in proxy mode. If the same client establishes multiple connections in parallel via the same proxy, the current limit of 5 parallel connections may not be enough. In your nginx logs, errors like limiting connections by zone "default" occur.

To mitigate the issue, you have to increase the limit_conn like:

'nginx-hardening' => {
    'options' => {
      'limit_conn' => 'default 15'
    }
  }

Nginx fails with "No such file or directory /etc/nginx/dh2048.pem"

It seems like the /etc/nginx/conf.d/90.hardening.conf is generated and after that Nginx is restarted.
This file contains the ssl_dhparam /etc/nginx/dh2048.pem; directive, but execute 'generate_dh_group' is at the end of the recipe so Nginx fails to restart...

Moving the execute resource before the template resource helps.

Support for nginx >= 10.0.0

Is your feature request related to a problem? Please describe.
This hardening cookbook does not work due to breaking changes in nginx upstream cookbook >= 10.0.0.

Describe the solution you'd like
Refactor this cookbook to support nginx cookbook >= 10.0.0.

Describe alternatives you've considered
Currently there are two options:

  • pin to older version of nginx cookbook
  • configure the nginx cookbook with the settings from this cookbook

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.