All Projects → dev-sec → Ansible Nginx Hardening

dev-sec / Ansible Nginx Hardening

This Ansible role provides secure nginx configurations.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Ansible Nginx Hardening

Ansible Collection Hardening
This Ansible collection provides battle tested hardening for Linux, SSH, nginx, MySQL
Stars: ✭ 2,543 (+1312.78%)
Mutual labels:  ansible, playbook, hardening, role, protection, nginx
Ansible Mysql Hardening
This Ansible role provides security configuration for MySQL.
Stars: ✭ 132 (-26.67%)
Mutual labels:  ansible, playbook, hardening, role, protection
Ansible Ssh Hardening
This Ansible role provides numerous security-related ssh configurations, providing all-round base protection.
Stars: ✭ 746 (+314.44%)
Mutual labels:  ansible, playbook, hardening, role, protection
Ansible Role Php
Ansible Role - PHP
Stars: ✭ 396 (+120%)
Mutual labels:  ansible, playbook, role
Ansible Role Htpasswd
Ansible Role - htpasswd
Stars: ✭ 17 (-90.56%)
Mutual labels:  ansible, role, nginx
Ansible Role Nginx
Ansible Role - Nginx
Stars: ✭ 632 (+251.11%)
Mutual labels:  ansible, role, nginx
Ansible Role Mysql
Ansible Role - MySQL
Stars: ✭ 826 (+358.89%)
Mutual labels:  ansible, playbook, role
Ansible Role Ruby
Ansible Role - Ruby
Stars: ✭ 77 (-57.22%)
Mutual labels:  ansible, playbook, role
Ansible Role K3s
Ansible role for installing k3s as either a standalone server or HA cluster.
Stars: ✭ 132 (-26.67%)
Mutual labels:  ansible, playbook
Ansible Role Dotfiles
Ansible Role - Easy and flexible dotfile installation.
Stars: ✭ 133 (-26.11%)
Mutual labels:  ansible, role
Redfish Ansible Module
Ansible modules for Out-Of-Band Controllers using Redfish APIs
Stars: ✭ 139 (-22.78%)
Mutual labels:  ansible, playbook
Ansible Role Nfs
Ansible Role - NFS
Stars: ✭ 141 (-21.67%)
Mutual labels:  ansible, role
Ansible Gitlab Runner
Ansible role to install gitlab-runner
Stars: ✭ 143 (-20.56%)
Mutual labels:  ansible, role
Ansible Role Repo Epel
Ansible Role - EPEL Repository for RHEL/CentOS
Stars: ✭ 149 (-17.22%)
Mutual labels:  ansible, role
Vagrant Elastic Stack
Giving the Elastic Stack a try in Vagrant
Stars: ✭ 131 (-27.22%)
Mutual labels:  ansible, nginx
Ansible Role Logstash
Ansible Role - Logstash
Stars: ✭ 136 (-24.44%)
Mutual labels:  ansible, role
Mattermost Ansible
Ansible playbook to provide a turnkey solution for the Team Edition of Mattermost
Stars: ✭ 126 (-30%)
Mutual labels:  ansible, playbook
Casl Ansible
Ansible automation for Managing OpenShift Container Platform clusters
Stars: ✭ 123 (-31.67%)
Mutual labels:  ansible, playbook
Ansible Role Git
Ansible Role - Git
Stars: ✭ 153 (-15%)
Mutual labels:  ansible, role
Nginx
A fairly flexible and feature full Ansible role for the NGINX web server.
Stars: ✭ 151 (-16.11%)
Mutual labels:  ansible, nginx

nginx-hardening (Ansible Role)

Attention: This role has been migrated to our hardening-collection:

Requirements

  • Ansible >= 2.5

Role Variables

  • nginx_client_body_buffer_size
    • Default: 1k
    • Description: 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_remove_default_site
    • Default: true
    • Description: Disables the default site. Set to false to enable the default site in nginx.
  • nginx_client_max_body_size
    • Default: 1k
    • Description: Sets 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 41 3 (Request Entity Too Large) error is returned to the client.
  • nginx_keepalive_timeout
    • Default: 5 5
    • Description: 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 op tional second parameter sets a value in the “Keep-Alive: timeout=time” response header field.
  • nginx_server_tokens
    • Default: off
    • Description: 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 head er.
  • nginx_client_header_buffer_size
    • Default: 1k
    • Description: Sets buffer size for reading client request header. For most requests, a buffer of 1K bytes is enough.
  • nginx_large_client_header_buffers
    • Default: 2 1k
    • Description: Sets the maximum number and size of buffers used for reading large client request header.
  • nginx_client_body_timeout
    • Default: 10
    • Description: Defines a timeout for reading client request body.
  • nginx_client_header_timeout
    • Default: 10
    • Description: Defines a timeout for reading client request header.
  • nginx_send_timeout
    • Default: 10
    • Description: Sets a timeout for transmitting a response to the client.
  • nginx_limit_conn_zone
    • Default: $binary_remote_addr zone=default:10m
    • Description: Sets parameters for a shared memory zone that will keep states for various keys.
  • nginx_limit_conn
    • Default: default 5
    • Description: Sets the shared memory zone and the maximum allowed number of connections for a given key value.
  • nginx_add_header
    • Default: [ "X-Frame-Options SAMEORIGIN", "X-Content-Type-Options nosniff", "X-XSS-Protection \"1; mode=block\"" ]
    • Description:Adds the specified field to a response header provided that the response code equals 200, 201, 204, 206, 301, 302, 303, 304, or 307.
  • nginx_ssl_protocols
    • Default: TLSv1.2
    • Description: Specifies the SSL protocol which should be used.
  • nginx_ssl_ciphers
    • Default: see defaults.yml
    • Description: Specifies the TLS ciphers which should be used.
  • nginx_ssl_prefer_server_ciphers
    • Default: on
    • Description: Specifies that server ciphers should be preferred over client ciphers when using the TLS protocols. Set to false to disable it.
  • nginx_dh_size
    • Default: 2048
    • Description: Specifies the length of DH parameters for EDH ciphers.

Installation

Install the role with ansible-galaxy:

ansible-galaxy install dev-sec.nginx-hardening

Example Playbook

- hosts: localhost
  roles:
    - dev-sec.nginx-hardening

Local Testing

The preferred way of locally testing the role is to use Docker. You will have to install Docker on your system. See Get started for a Docker package suitable to for your system.

You can also use vagrant and Virtualbox or VMWare to run tests locally. You will have to install Virtualbox and Vagrant on your system. See Vagrant Downloads for a vagrant 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.

Next install test-kitchen:

# Install dependencies
gem install bundler
bundle install

Testing with Docker

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

# test on all machines
bundle exec kitchen test

# for development
bundle exec kitchen create default-ubuntu-1204
bundle exec kitchen converge default-ubuntu-1204

Testing with Virtualbox

# fast test on one machine
KITCHEN_YAML=".kitchen.vagrant.yml" bundle exec kitchen test nginx-ansible-19-ubuntu-1404

# test on all machines
KITCHEN_YAML=".kitchen.vagrant.yml" bundle exec kitchen test

# for development
KITCHEN_YAML=".kitchen.vagrant.yml" bundle exec kitchen create nginx-ansible-19-ubuntu-1404
KITCHEN_YAML=".kitchen.vagrant.yml" bundle exec kitchen converge nginx-ansible-19-ubuntu-1404

For more information see test-kitchen

Contributing

See contributor guideline.

License and Author

  • Author:: Sebastian Gumprich

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].