{"id":13753431,"url":"https://github.com/dev-sec/ansible-nginx-hardening","last_synced_at":"2025-05-09T21:34:42.332Z","repository":{"id":41390126,"uuid":"64212361","full_name":"dev-sec/ansible-nginx-hardening","owner":"dev-sec","description":"This Ansible role provides secure nginx configurations.","archived":true,"fork":false,"pushed_at":"2020-11-16T19:55:13.000Z","size":68,"stargazers_count":188,"open_issues_count":0,"forks_count":40,"subscribers_count":31,"default_branch":"master","last_synced_at":"2024-11-16T06:30:20.601Z","etag":null,"topics":["ansible","hardening","nginx","playbook","protection","role"],"latest_commit_sha":null,"homepage":"http://dev-sec.io/","language":"Ruby","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dev-sec.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-26T10:24:29.000Z","updated_at":"2024-11-11T18:57:23.000Z","dependencies_parsed_at":"2022-09-06T05:51:11.420Z","dependency_job_id":null,"html_url":"https://github.com/dev-sec/ansible-nginx-hardening","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-sec%2Fansible-nginx-hardening","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-sec%2Fansible-nginx-hardening/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-sec%2Fansible-nginx-hardening/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-sec%2Fansible-nginx-hardening/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dev-sec","download_url":"https://codeload.github.com/dev-sec/ansible-nginx-hardening/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253328848,"owners_count":21891538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","hardening","nginx","playbook","protection","role"],"created_at":"2024-08-03T09:01:22.040Z","updated_at":"2025-05-09T21:34:42.074Z","avatar_url":"https://github.com/dev-sec.png","language":"Ruby","funding_links":[],"categories":["Ruby","role"],"sub_categories":[],"readme":"# nginx-hardening (Ansible Role)\n\n\n**Attention:** This role has been migrated to our hardening-collection:\n* https://github.com/dev-sec/ansible-os-hardening/\n* https://galaxy.ansible.com/devsec/hardening\n\n\n## Requirements\n\n* Ansible \u003e= 2.5\n\n## Role Variables\n\n* [nginx_client_body_buffer_size][]\n  * Default: `1k`\n  * 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.\n* nginx_remove_default_site\n  * Default: `true`\n  * Description: Disables the default site. Set to false to enable the default site in nginx.\n* [nginx_client_max_body_size][]\n  * Default: `1k`\n  * 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\n3 (Request Entity Too Large) error is returned to the client.\n* [nginx_keepalive_timeout][]\n  * Default: `5 5`\n  * 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\ntional second parameter sets a value in the “Keep-Alive: timeout=time” response header field.\n* [nginx_server_tokens][]\n  * Default: `off`\n  * 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\ner.\n* [nginx_client_header_buffer_size][]\n  * Default: `1k`\n  * Description:  Sets buffer size for reading client request header. For most requests, a buffer of 1K bytes is enough.\n* [nginx_large_client_header_buffers][]\n  * Default: `2 1k`\n  * Description: Sets the maximum number and size of buffers used for reading large client request header.\n* [nginx_client_body_timeout][]\n  * Default: `10`\n  * Description: Defines a timeout for reading client request body.\n* [nginx_client_header_timeout][]\n  * Default: `10`\n  * Description: Defines a timeout for reading client request header.\n* [nginx_send_timeout][]\n  * Default: `10`\n  * Description: Sets a timeout for transmitting a response to the client.\n* [nginx_limit_conn_zone][]\n  * Default: `$binary_remote_addr zone=default:10m`\n  * Description: Sets parameters for a shared memory zone that will keep states for various keys.\n* [nginx_limit_conn][]\n  * Default: `default 5`\n  * Description: Sets the shared memory zone and the maximum allowed number of connections for a given key value.\n* [nginx_add_header][]\n  * Default: `[ \"X-Frame-Options SAMEORIGIN\", \"X-Content-Type-Options nosniff\", \"X-XSS-Protection \\\"1; mode=block\\\"\" ]`\n  * 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.\n* [nginx_ssl_protocols][]\n  * Default: `TLSv1.2`\n  * Description: Specifies the SSL protocol which should be used.\n* [nginx_ssl_ciphers][]\n  * Default: *see defaults.yml*\n  * Description: Specifies the TLS ciphers which should be used.\n* [nginx_ssl_prefer_server_ciphers][]\n  * Default: `on`\n  * Description: Specifies that server ciphers should be preferred over client ciphers when using the TLS protocols. Set to false to disable it.\n* [nginx_dh_size][]\n  * Default: `2048`\n  * Description: Specifies the length of DH parameters for EDH ciphers.\n\n## Installation\n\nInstall the role with ansible-galaxy:\n\n```\nansible-galaxy install dev-sec.nginx-hardening\n```\n\n## Example Playbook\n\n    - hosts: localhost\n      roles:\n        - dev-sec.nginx-hardening\n\n## Local Testing\n\nThe preferred way of locally testing the role is to use Docker. You will have to install Docker on your system. See [Get started](https://docs.docker.com/) for a Docker package suitable to for your system.\n\nYou 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](http://downloads.vagrantup.com/) 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](http://kitchen.ci/docs/getting-started).\n\nNext install test-kitchen:\n\n```bash\n# Install dependencies\ngem install bundler\nbundle install\n```\n\n### Testing with Docker\n\n```\n# fast test on one machine\nbundle exec kitchen test default-ubuntu-1204\n\n# test on all machines\nbundle exec kitchen test\n\n# for development\nbundle exec kitchen create default-ubuntu-1204\nbundle exec kitchen converge default-ubuntu-1204\n```\n\n### Testing with Virtualbox\n\n```\n# fast test on one machine\nKITCHEN_YAML=\".kitchen.vagrant.yml\" bundle exec kitchen test nginx-ansible-19-ubuntu-1404\n\n# test on all machines\nKITCHEN_YAML=\".kitchen.vagrant.yml\" bundle exec kitchen test\n\n# for development\nKITCHEN_YAML=\".kitchen.vagrant.yml\" bundle exec kitchen create nginx-ansible-19-ubuntu-1404\nKITCHEN_YAML=\".kitchen.vagrant.yml\" bundle exec kitchen converge nginx-ansible-19-ubuntu-1404\n```\n\nFor more information see [test-kitchen](http://kitchen.ci/docs/getting-started)\n\n## Contributing\n\nSee [contributor guideline](CONTRIBUTING.md).\n\n## License and Author\n\n* Author:: Sebastian Gumprich\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n[1]: http://travis-ci.org/dev-sec/ansible-nginx-hardening\n[2]: https://gitter.im/dev-sec/general\n[3]: https://galaxy.ansible.com/dev-sec/nginx-hardening/\n\n[nginx_client_body_buffer_size]: http://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_buffer_size\n[nginx_client_max_body_size]: http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size\n[nginx_keepalive_timeout]: http://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_timeout\n[nginx_server_tokens]: http://nginx.org/en/docs/http/ngx_http_core_module.html#server_tokens\n[nginx_more_clear_headers]: http://nginx.org/en/docs/http/ngx_http_headers_module.html#add_header\n[nginx_client_header_buffer_size]: http://nginx.org/en/docs/http/ngx_http_core_module.html#client_header_buffer_size\n[nginx_large_client_header_buffers]: http://nginx.org/en/docs/http/ngx_http_core_module.html#large_client_header_buffers\n[nginx_client_body_timeout]: http://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_timeout\n[nginx_client_header_timeout]: http://nginx.org/en/docs/http/ngx_http_core_module.html#client_header_timeout\n[nginx_send_timeout]: http://nginx.org/en/docs/http/ngx_http_core_module.html#send_timeout\n[nginx_limit_conn_zone]: http://nginx.org/en/docs/http/ngx_http_limit_conn_module.html#limit_conn_zone\n[nginx_limit_conn]: http://nginx.org/en/docs/http/ngx_http_limit_conn_module.html#limit_conn\n[nginx_add_header]: http://nginx.org/en/docs/http/ngx_http_headers_module.html#add_header\n[nginx_ssl_protocols]: http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_protocols\n[nginx_ssl_ciphers]: http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_ciphers\n[nginx_ssl_prefer_server_ciphers]: http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_prefer_server_ciphers\n[nginx_dh_size]: http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_dhparam\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-sec%2Fansible-nginx-hardening","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdev-sec%2Fansible-nginx-hardening","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-sec%2Fansible-nginx-hardening/lists"}