Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
Add nginx_http_extra_params variable in default vars (#149)
Browse files Browse the repository at this point in the history
* add extra param to append to defaults

* make nginx default param var
assign default param var to  nginx params
update readme with example

* remove error from example

* update numbering

* fix syntax

* move default params to /vars
as suggested by @jdauphant
  • Loading branch information
T authored and jdauphant committed Jan 6, 2017
1 parent 39744b6 commit 37de6ef
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,27 @@ for details.
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for
```
4) Install nginx and add extra variables to default config
```yaml
-hosts: all
vars:
- my_extra_params:
- client_max_body_size 200M
# retain defaults and add additional `client_max_body_size` param
roles:
- role: jdauphant.nginx
nginx_http_params: "{{ nginx_http_params_defaults + my_extra_params }}"
```
Note: Each site added is represented by list of hashes, and the configurations
generated are populated in /etc/nginx/site-available/, a link is from /etc/nginx/site-enable/ to /etc/nginx/site-available
The file name for the specific site configurtaion is specified in the hash
with the key "file_name", any valid server directives can be added to hash.
Additional configuration are created in /etc/nginx/conf.d/
4) Install Nginx , add 2 sites (different method) and add additional configuration
5) Install Nginx , add 2 sites (different method) and add additional configuration
```yaml
---
Expand Down Expand Up @@ -174,7 +187,7 @@ Additional configuration are created in /etc/nginx/conf.d/
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for
```
5) Install Nginx , add 2 sites, add additional configuration and an upstream configuration block
6) Install Nginx , add 2 sites, add additional configuration and an upstream configuration block
```yaml
---
Expand Down Expand Up @@ -219,7 +232,7 @@ Additional configuration are created in /etc/nginx/conf.d/
- bar:$apr1$H2GihkSo$PwBeV8cVWFFQlnAJtvVCQ. # bar:demo , generated by : htpasswd -nb bar demo
```
6) Install Nginx, add a site and use special yaml syntax to make the location blocks multiline for clarity
7) Install Nginx, add a site and use special yaml syntax to make the location blocks multiline for clarity
```yaml
---
Expand Down Expand Up @@ -249,7 +262,7 @@ Additional configuration are created in /etc/nginx/conf.d/
proxy_set_header Host $myhost;
}
```
7) Example to use this role with my ssl-certs role to generate or copie ssl certificate ( https://galaxy.ansible.com/list#/roles/3115 )
8) Example to use this role with my ssl-certs role to generate or copie ssl certificate ( https://galaxy.ansible.com/list#/roles/3115 )
```yaml
- hosts: all
roles:
Expand All @@ -266,7 +279,7 @@ Additional configuration are created in /etc/nginx/conf.d/
- root "/usr/share/nginx/html"
- index index.html
```
8) Site configuration using a custom template.
9) Site configuration using a custom template.
Instead of defining a site config file using a list of attributes,
you may use a hash that indicates an alternate template.
Additional hash elements are accessible inside the template through
Expand Down
10 changes: 1 addition & 9 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,7 @@ nginx_extra_root_params: []
nginx_events_params:
- worker_connections {% if nginx_max_clients is defined %}{{nginx_max_clients}}{% else %}512{% endif %}

nginx_http_params:
- sendfile "on"
- tcp_nopush "on"
- tcp_nodelay "on"
- keepalive_timeout "65"
- access_log "{{nginx_log_dir}}/access.log"
- "error_log {{nginx_log_dir}}/error.log {{nginx_error_log_level}}"
- server_tokens off
- types_hash_max_size 2048
nginx_http_params: "{{ nginx_http_default_params }}"

nginx_stream_params: []

Expand Down
10 changes: 10 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,13 @@ nginx_env:
nginx_installation_types_using_service: ["packages", "configuration-only"]

nginx_is_el: "{{ ansible_distribution in ['RedHat', 'CentOS'] }}"

nginx_http_default_params:
- sendfile "on"
- tcp_nopush "on"
- tcp_nodelay "on"
- keepalive_timeout "65"
- access_log "{{nginx_log_dir}}/access.log"
- "error_log {{nginx_log_dir}}/error.log {{nginx_error_log_level}}"
- server_tokens off
- types_hash_max_size 2048

0 comments on commit 37de6ef

Please sign in to comment.