{"id":21400278,"url":"https://github.com/oefenweb/ansible-nginx","last_synced_at":"2025-07-13T21:31:16.823Z","repository":{"id":54180347,"uuid":"58400541","full_name":"Oefenweb/ansible-nginx","owner":"Oefenweb","description":"Ansible role to set up (the latest version of) NGINX in Debian-like systems","archived":false,"fork":false,"pushed_at":"2023-11-02T11:05:43.000Z","size":98,"stargazers_count":3,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-11-02T11:37:26.752Z","etag":null,"topics":["ansible","debian","http","https","load-balancing","ubuntu","webserver"],"latest_commit_sha":null,"homepage":"","language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Oefenweb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-05-09T18:57:38.000Z","updated_at":"2023-02-07T20:24:25.000Z","dependencies_parsed_at":"2023-11-02T11:35:06.080Z","dependency_job_id":null,"html_url":"https://github.com/Oefenweb/ansible-nginx","commit_stats":null,"previous_names":[],"tags_count":4,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oefenweb%2Fansible-nginx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oefenweb%2Fansible-nginx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oefenweb%2Fansible-nginx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oefenweb%2Fansible-nginx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Oefenweb","download_url":"https://codeload.github.com/Oefenweb/ansible-nginx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225917762,"owners_count":17544945,"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","debian","http","https","load-balancing","ubuntu","webserver"],"created_at":"2024-11-22T15:20:33.972Z","updated_at":"2024-11-22T15:20:34.476Z","avatar_url":"https://github.com/Oefenweb.png","language":"Jinja","funding_links":[],"categories":[],"sub_categories":[],"readme":"## nginx\n\n[![CI](https://github.com/Oefenweb/ansible-nginx/workflows/CI/badge.svg)](https://github.com/Oefenweb/ansible-nginx/actions?query=workflow%3ACI)\n[![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-nginx-blue.svg)](https://galaxy.ansible.com/Oefenweb/nginx)\n\nSet up (the latest version of) [NGINX](http://nginx.org/) in Debian-like systems.\n\n#### Requirements\n\n* `software-properties-common` (will be installed)\n* `dirmngr` (will be installed)\n\n#### Variables\n\n* `nginx_use_ppa`: [default: `true`]: Whether or not to add the PPA (for installation)\n\n* `nginx_version`: [default: `stable`]: Version to install (e.g. `development`)\n\n* `nginx_dependencies`: [default: `['nginx']`]: Packages to install\n* `nginx_install`: [default: `[]`]: Additional packages to install\n\n* `nginx_core_directives`: [default: `[\"user {{ nginx_preset_user }} {{ nginx_preset_group }}\", \"worker_processes {{ nginx_preset_processes }}\", \"pid {{ nginx_preset_pid }}\"]`]: Core functionality directives ([see](https://nginx.org/en/docs/ngx_core_module.html#directives))\n* `nginx_events_directives`: [default: `[\"worker_connections {{ nginx_preset_worker_connections }}\"]`]: Events functionality directives ([see](http://nginx.org/en/docs/ngx_core_module.html#events))\n* `nginx_http_directives`: [default: `[]`]: HTTP functionality directives ([see](https://nginx.org/en/docs/http/ngx_http_core_module.html))\n* `nginx_stream_directives`: [optional]: Stream functionality directives ([see](https://nginx.org/en/docs/stream/ngx_stream_core_module.html))\n* `nginx_mail_directives`: [optional]: Mail functionality directives ([see](https://nginx.org/en/docs/mail/ngx_mail_core_module.html))\n\n* `nginx_present_paths`: [default: `[]`]: Directories to be created\n* `nginx_absent_paths`: [default: `[]`]: Paths to be removed\n\n* `nginx_conf_d_include_files`: [default: `[]`]: `conf.d` file declarations (in `/etc/nginx/conf.d`)\n* `nginx_conf_d_include_files.{n}.name`: [required]: The name of the file (e.g. `ssl.conf`)\n\n* `nginx_snippets_include_files`: [default: `[]`]: `snippets` file declarations (in `/etc/nginx/snippets`)\n* `nginx_snippets_include_files.{n}.name`: [required]: The name of the file (e.g. `fastcgi_param`)\n\n* `nginx_sites_available_include_files`: [default: `[]`]: `sites_available` file declarations (in `/etc/nginx/sites_available`)\n* `nginx_sites_available_include_files.{n}.name`: [required]: The name of the file (e.g. `default-80.conf`)\n* `nginx_sites_available_include_files.{n}.state`: [default `enabled`]: The state of the file. Settings this to `enabled` will create a symlink in `sites_enabled`\n\n* `nginx_streams_available_include_files`: [default: `[]`]: `streams_available` file declarations (in `/etc/nginx/streams_available`)\n* `nginx_streams_available_include_files.{n}.name`: [required]: The name of the file (e.g. `dns.conf`)\n* `nginx_streams_available_include_files.{n}.state`: [default `enabled`]: The state of the file. Settings this to `enabled` will create a symlink in `streams_enabled`\n\n* `nginx_mails_available_include_files`: [default: `[]`]: `mails_available` file declarations (in `/etc/nginx/mails_available`)\n* `nginx_mails_available_include_files.{n}.name`: [required]: The name of the file (e.g. `mail.conf`)\n* `nginx_mails_available_include_files.{n}.state`: [default `enabled`]: The state of the file. Settings this to `enabled` will create a symlink in `mails_enabled`\n\n* `nginx_ssl_map`: [default: `[]`]: SSL declarations\n* `nginx_ssl_map.{n}.src`: The local path of the file to copy, can be absolute or relative (e.g. `../../../files/nginx/etc/nginx/ssl/star-example-com.pem`)\n* `nginx_ssl_map.{n}.dest`: The remote path of the file to copy (e.g. `/etc/nginx/ssl/star-example-com.pem`)\n* `nginx_ssl_map.{n}.owner`: The name of the user that should own the file (optional, default `root`)\n* `nginx_ssl_map.{n}.group`: The name of the group that should own the file (optional, default `root`)\n* `nginx_ssl_map.{n}.mode`: The mode of the file, such as 0644 (optional, default `0640`)\n\n## Dependencies\n\nNone\n\n#### Examples\n\n##### Simple, single vhost on port 80\n\n```yaml\n---\n- hosts: all\n  roles:\n    - oefenweb.nginx\n  vars:\n    nginx_http_directives:\n      - |\n        include {{ nginx_conf_path }}/mime.types;\n        default_type application/octet-stream;\n\n        include {{ nginx_conf_d.path }}/*.conf;\n        include {{ nginx_sites_enabled.path }}/*.conf;\n\n    nginx_sites_available_include_files:\n      - name: default-80.conf\n        directives:\n          - |\n            server {\n              listen 80;\n              server_name _ default-80 \"\";\n              location / {\n                root   /usr/share/nginx/html;\n                index  index.html index.htm;\n              }\n            }\n```\n\n##### Advanced, multiple vhosts, stream and mail\n\n```yaml\n---\n- hosts: all\n  roles:\n    - oefenweb.nginx\n  vars:\n    nginx_http_directives:\n      - |\n        ##\n        # Basic Settings\n        ##\n        sendfile on;\n        tcp_nopush on;\n        tcp_nodelay on;\n        keepalive_timeout 65;\n        types_hash_max_size 2048;\n        # server_tokens off;\n\n        # server_names_hash_bucket_size 64;\n        # server_name_in_redirect off;\n\n        include {{ nginx_conf_path }}/mime.types;\n        default_type application/octet-stream;\n\n        ##\n        # Logging Settings\n        ##\n        access_log {{ nginx_var_log.path }}/access.log;\n        error_log {{ nginx_var_log.path }}/error.log;\n\n        ##\n        # Virtual Host Configs\n        ##\n        include {{ nginx_conf_d.path }}/*.conf;\n        include {{ nginx_sites_enabled.path }}/*.conf;\n\n    # optional\n    nginx_stream_directives:\n      - \"include {{ nginx_streams_enabled.path }}/*.conf\"\n\n    # optional\n    nginx_mail_directives:\n      - |\n        server_name       mail.example.com;\n        auth_http         localhost:9000/cgi-bin/nginxauth.cgi;\n\n        imap_capabilities IMAP4rev1 UIDPLUS IDLE LITERAL+ QUOTA;\n\n        pop3_auth         plain apop cram-md5;\n        pop3_capabilities LAST TOP USER PIPELINING UIDL;\n\n        smtp_auth         login plain cram-md5;\n        smtp_capabilities \"SIZE 10485760\" ENHANCEDSTATUSCODES 8BITMIME DSN;\n        xclient           off;\n\n        include {{ nginx_mails_enabled.path }}/*.conf;\n\n    nginx_conf_d_include_files:\n      - \"{{ nginx_preset_conf_d_ssl }}\"\n      - \"{{ nginx_preset_conf_d_gzip }}\"\n\n    nginx_snippets_include_files:\n      - \"{{ nginx_preset_conf_d_fastcgi_param }}\"\n      - \"{{ nginx_preset_conf_d_scgi_param }}\"\n      - \"{{ nginx_preset_conf_d_uwsgi_param }}\"\n\n    nginx_sites_available_include_files:\n      - name: default-80.conf\n        directives:\n          - |\n            server {\n              listen 80;\n              server_name _ default-80 \"\";\n              location / {\n                root   /usr/share/nginx/html;\n                index  index.html index.htm;\n              }\n            }\n\n      - name: default-81.conf\n        directives:\n          - |\n            server {\n              listen 81;\n              server_name _ default-81 \"\";\n              root /usr/share/nginx/html;\n              location / { try_files $uri $uri/ /index.html; }\n              location /images/ { try_files $uri $uri/ /index.html; }\n            }\n      - name: default-82.conf\n        directives:\n          - server { listen 82; server_name _ default-82 \"\"; root /usr/share/nginx/html; location / { root /usr/share/nginx/html; index index.html index.htm; } }\n      - name: default-83.conf\n        directives:\n          - |\n            server {\n              listen 83;\n              server_name _ default-83 \"\";\n              root /usr/share/nginx/html;\n              location / {\n                root /usr/share/nginx/html;\n                index index.html index.htm;\n              }\n            }\n\n    nginx_streams_available_include_files:\n      - name: dns.conf\n        directives:\n          - |\n            upstream dns {\n               server 8.8.8.8:53;\n               server 8.8.4.4:53;\n            }\n\n            server {\n              listen {{ ansible_lo['ipv4']['address'] }}:53 udp;\n              proxy_responses 1;\n              proxy_timeout 20s;\n              proxy_pass dns;\n            }\n\n    nginx_mails_available_include_files:\n      - name: mail.conf\n        directives:\n          - |\n            server {\n              listen   1025;\n              protocol smtp;\n            }\n            server {\n              listen   1110;\n              protocol pop3;\n              proxy_pass_error_message on;\n            }\n            server {\n              listen   1143;\n              protocol imap;\n            }\n            server {\n              listen   1587;\n              protocol smtp;\n            }\n\n    nginx_absent_paths:\n      - \"{{ nginx_conf_path }}/fastcgi_params\"\n      - \"{{ nginx_conf_path }}/scgi_params\"\n      - \"{{ nginx_conf_path }}/uwsgi_params\"\n\n      - \"{{ nginx_conf_d.path }}/default.conf\"\n```\n\n#### License\n\nMIT\n\n#### Author Information\n\nMischa ter Smitten (based on work of [jdauphant](https://github.com/jdauphant) and [geerlingguy](https://github.com/geerlingguy))\n\n#### Feedback, bug-reports, requests, ...\n\nAre [welcome](https://github.com/Oefenweb/ansible-nginx/issues)!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foefenweb%2Fansible-nginx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foefenweb%2Fansible-nginx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foefenweb%2Fansible-nginx/lists"}