Skip to content

Refactor all minor modules #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 81 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ BREAKING CHANGES:
* The `health_check` parameter within the `server` dictionary is no longer supported. Instead, manually set `max_fails` and `fail_timeout`.
* Refactor the `proxy` HTTP config template into its own separate file. All variables have changed (check [`defaults/main/template.yml`](https://github.com/nginxinc/ansible-role-nginx-config/blob/main/defaults/main/template.yml) for examples):
* All `proxy_*` related variables now live under the `proxy` dictionary key, with the exception of `proxy_pass` and `proxy_cache_path`. You can specify the `proxy` dictionary key inside the `http`, `server`, and `location` contexts.
* Remove the `nginx_config_main_template.http_settings.cache` dictionary variable. Use `nginx_config_http_template.*.proxy_cache_path` instead.
* Remove the `location.websocket` variable. Use `location.proxy.set_header` instead:
* Removed the `nginx_config_main_template.http_settings.cache` dictionary variable. Use `nginx_config_http_template.*.proxy_cache_path` instead.
* Removed the `location.websocket` variable. Use `location.proxy.set_header` instead:
```yaml
proxy:
set_header:
Expand All @@ -36,6 +36,85 @@ BREAKING CHANGES:
* Refactor the `auth` HTTP config template into its own separate file, as well as add support for `auth_jwt` directives. All variables have changed (check [`defaults/main/template.yml`](https://github.com/nginxinc/ansible-role-nginx-config/blob/main/defaults/main/template.yml) for examples):
* All the various `auth` variables now live within their respective `auth` dictionaries.
* `auth` configs are now supported within the `http`, `server`, and `location` contexts.
* Refactor the `autoindex` NGINX config template into its own separate file and added missing `autoindex` module directives. All variables have changed (check [`defaults/main/template.yml`](https://github.com/nginxinc/ansible-role-nginx-config/blob/main/defaults/main/template.yml) for examples):
* The `autoindex` directives now live within the `autoindex` dictionary.
* The `autoindex` dictionary now lives in the HTTP template config instead of the Main template config.
* Refactor the `add_headers` dictionary into a `headers` dictionary that now includes all the `headers` module directives:
* The `add_headers` directive now lives within the `headers` dictionary.
* Refactor the `access_log` and `log_format` directives into a `log` dictionary that now includes all the `log` module directives:
* An `access` and `format` directive now lives within the `log` dictionary.
* The `log` dictionary HTTP context now lives in the HTTP template config instead of the Main template config.
* Refactor the `keyval` directives into its own dictionary:
* Both `keyval` directives now live within the `keyval` dictionary.
* The `keyval` dictionary now lives in the HTTP template config instead of the Main template config.
* Refactor the `return` and `rewrite` directives into their own dictionary that now includes all the `rewrite` module directives:
* The `rewrites` directive has transitioned from a list of one liners
```yaml
rewrites:
- (.*).html(.*) $1$2
```
to
```yaml
rewrites:
- regex: (.*).html(.*)
replacement: $1$2
```
* The `return` directive has transitioned from a slightly complex dictionary structure (wherein the `location` variable didn't necessarily have any effect)
```yaml
returns:
return301:
location: ^~ /old-path
code: 301
value: http://$host/new-path
```
to a slightly less complicated structure
```yaml
return: # 200 -- Alternatively you could also include a code here instead of fleshing out the dictionary.
code: 200
text: nginx
```
* Refactor the `sub_filter` directives into a `sub_filter` dictionary:
* The only major difference is that one liners under the `sub_filters` dictionary key have changed from
```yaml
sub_filters:
- sub_filter 'server_hostname' '$hostname';
```
to
```yaml
sub_filters:
- string: server_hostname
replacement: $hostname
```
* Removed the `server.http_demo_conf` dictionary. Use `server.sub_filters` instead:
```yaml
sub_filter:
sub_filters:
- string: server_hostname
replacement: $hostname
- string: server_address
replacement: $server_addr:$server_port
- string: server_url
replacement: $request_uri
- string: remote_addr
replacement: '$remote_addr:$remote_port'
- string: server_date
replacement: $time_local
- string: client_browser
replacement: $http_user_agent
- string: request_id
replacement: $request_id
- string: nginx_version
replacement: $nginx_version
- string: document_root
replacement: $document_root
- string: proxied_for_ip
replacement: $http_x_forwarded_for
```
* The `sub_filter` dictionary HTTP context now lives in the HTTP template config instead of the Main template config.
* Refactor the `limit_req` directive into its own dictionary:
* The `limit_req` directives now live within the `limit_req` dictionary.
* The `limit_req` dictionary now lives in the HTTP template config instead of the Main template config.

* Rename some NGINX template config parameters to align with NGINX directive names:
* Rename `html_file_location` to `root`.
* Rename `html_file_name` to `index`.
Expand Down
74 changes: 74 additions & 0 deletions defaults/main/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,80 @@ nginx_config_http_template:
auth_basic: # Optional -- Configure basic auth
realm: false # Optional -- Set to 'false' to set auth_basic to 'off'
user_file: /path/to/file # Optional
autoindex: # Optional -- Configure autoindex
enable: false # Optional
exact_size: true # Optional
format: html # Optional
localtime: false # Optional
headers: # Optional -- Configure headers
add_headers: # Optional
- name: Strict-Transport-Security # Required
value: '"max-age=15768000; includeSubDomains"' # Required
always: false # Optional
add_trailers: # Optional
- name: Strict-Transport-Security # Required
value: '"max-age=15768000; includeSubDomains"' # Required
always: false # Optional
expires: # Optional
- modified: true # Optional
time: "12h" # Optional
- epoch # Optional -- Can also be 'max'
limit_req: # Optional -- Configure request limits
limit_reqs: # Optional
- zone: one # Required
burst: 5 # Optional
delay: false # Optional -- Set it to 'false' to set it to 'nodelay', otherwise specify a delay value
dry_run: false # Optional
log_level: error # Optional
status: 503 # Optional
zones: # Optional
- key: $binary_remote_addr # Required
name: one # Required
size: 1m # Required
rate: 10r/s # Required
sync: false # Optional
log: # Optional -- Configure logs
access: # Optional
- path: /var/log/nginx/access.log # Required
format: main # Optional
buffer: 1m # Optional
gzip: # Optional -- Can also be set to 'true'
level: 5 # Optional
flush: 10h # Optional
if: $loggable # Optional
format: # Optional
- name: main # Required
escape: default # Optional -- Can also be 'json' or 'none'
format: | # Required
'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'
open_log_file_cache: # Optional -- Can also be set to 'false'
max: 1000 # Required
inactive: 20s # Optional
min_uses: 2 # Optional
valid: 1m # Optional
rewrite: # Optional -- Configure rewrite directives
return: # Optional -- Can also be set to a return URL or code directly
- code: 200 # Optional
text: text # Optional
url: https://example.com # Optional
rewrites: # Optional
- regex: (.*).html(.*) # Required
replacement: $1$2 # Required
flag: last # Optional
log: false # Optional
set: # Optional
- variable: $var # Required
value: var # Required
uninitialized_variable_warn: true # Optional
sub_filter: # Optional -- Configure sub_filter directives
sub_filters: # Optional
- string: server_hostname # Required
replacement: $hostname # Required
last_modified: false # Optional
once: true # Optional
types: text/html # Optional
proxy_cache_path: # Optional -- Configure Proxy Cache Path
- path: /var/cache/nginx/proxy/backend # Required
levels: "1:1" # Optional
Expand Down
Loading