Skip to content

Commit 7c761b8

Browse files
authored
Add support for NGINX GRPC directives (#56)
1 parent c8996a4 commit 7c761b8

File tree

11 files changed

+285
-25
lines changed

11 files changed

+285
-25
lines changed

.github/workflows/galaxy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
name: Ansible Galaxy import
33
on:
44
release:
5+
types:
6+
- published
57
jobs:
68
galaxy:
79
name: Galaxy

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 0.3.3 (Unreleased)
4+
5+
ENHANCEMENTS:
6+
7+
* Add support for NGINX GRPC directives.
8+
* Only run GitHub actions Galaxy CI/CD workflow when a new release is published.
9+
* Update list of supported platforms.
10+
311
## 0.3.2 (January 11, 2021)
412

513
ENHANCEMENTS:

README.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,16 @@ The NGINX config Ansible role supports all platforms supported by [NGINX Open So
4040

4141
```yaml
4242
Alpine:
43-
- 3.9
4443
- 3.10
4544
- 3.11
4645
- 3.12
4746
CentOS:
48-
- 6
4947
- 7.4+
5048
- 8
5149
Debian:
5250
- stretch
5351
- buster
5452
RedHat:
55-
- 6
5653
- 7.4+
5754
- 8
5855
SUSE/SLES:
@@ -61,36 +58,33 @@ SUSE/SLES:
6158
Ubuntu:
6259
- xenial
6360
- bionic
64-
- eoan
6561
- focal
62+
- groovy
6663
```
6764
6865
### NGINX Plus
6966
7067
```yaml
7168
Alpine:
72-
- 3.9
7369
- 3.10
7470
- 3.11
71+
- 3.12
7572
Amazon Linux:
7673
- 2018.03
7774
Amazon Linux 2:
7875
- any
7976
CentOS:
80-
- 6.5+
8177
- 7.4+
8278
- 8
8379
Debian:
8480
- stretch
8581
- buster
8682
FreeBSD:
8783
- 11.2+
88-
- 12
84+
- 12.1+
8985
Oracle Linux:
90-
- 6.5+
9186
- 7.4+
9287
RedHat:
93-
- 6.5+
9488
- 7.4+
9589
- 8
9690
SUSE/SLES:
@@ -99,7 +93,6 @@ SUSE/SLES:
9993
Ubuntu:
10094
- xenial
10195
- bionic
102-
- eoan
10396
- focal
10497
```
10598

defaults/main/template.yml

Lines changed: 110 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,50 @@ nginx_config_main_template:
3434
# cpu_thresholds: # Optional
3535
# high: 100 # Required
3636
# low: 100 # Required
37-
# failure_mode_action: pass # Optional -- `pass` or `drop`
37+
# failure_mode_action: pass # Optional -- 'pass' or 'drop'
3838
# cookie_seed: encryptionseed # Optional
39-
# compressed_requests_action: drop # Optional -- `pass` or `drop`
40-
# request_buffer_overflow_action: pass # Optional -- `pass` or `drop`
39+
# compressed_requests_action: drop # Optional -- 'pass' or 'drop'
40+
# request_buffer_overflow_action: pass # Optional -- 'pass' or 'drop'
4141
# user_defined_signatures: [] # Optional list
42+
# app_protect: # Optional -- Configure NGINX App Protect
43+
# enable: false # Optional
44+
# policy_file: path # Optional
45+
# security_log_enable: false # Optional
46+
# security_log: # Optional
47+
# path: path # Required
48+
# destination: dest # Required
49+
# grpc_global: # Optional -- Configure GRPC
50+
# bind: # Optional -- Set to 'false' and remove/comment nested variables to disable grpc_bind
51+
# address: $remote_addr # Required
52+
# transparent: true # Optional
53+
# buffer_size: 4k # Optional
54+
# connect_timeout: 60s # Optional
55+
# hide_header: [] # Optional list
56+
# ignore_headers: [] # Optional list -- 'X-Accel-Redirect' or 'X-Accel-Charset'
57+
# intercept_errors: false # Optional
58+
# next_upstream: [] # Optional list
59+
# next_upstream_timeout: 0 # Optional
60+
# next_upstream_tries: 0 # Optional
61+
# pass_header: [] # Optional list
62+
# read_timeout: 60s # Optional
63+
# send_timeout: 60s # Optional
64+
# set_header: # Optional
65+
# - field: Accept-Encoding # Required
66+
# value: '""' # Required
67+
# socket_keepalive: false # Optional
68+
# ssl_certificate: fileLocation # Optional
69+
# ssl_certificate_key: fileLocation # Optional
70+
# ssl_ciphers: DEFAULT # Optional
71+
# ssl_conf_command: command # Optional
72+
# ssl_crl: fileLocation # Optional
73+
# ssl_name: serverName # Optional
74+
# ssl_password_file: fileLocation # Optional
75+
# ssl_protocols: [] # Optional list
76+
# ssl_server_name: false # Optional
77+
# ssl_session_reuse: true # Optional
78+
# ssl_trusted_certificate: fileLocation # Optional
79+
# ssl_verify: false # Optional
80+
# ssl_verify_depth: 1 # Optional
4281
access_log_format:
4382
- name: main
4483
format: |-
@@ -96,6 +135,38 @@ nginx_config_http_template:
96135
# security_log: # Optional
97136
# path: path # Required
98137
# destination: dest # Required
138+
# grpc_global: # Optional -- Configure GRPC
139+
# bind: # Optional -- Set to 'false' and remove/comment nested variables to disable grpc_bind
140+
# address: $remote_addr # Required
141+
# transparent: true # Optional
142+
# buffer_size: 4k # Optional
143+
# connect_timeout: 60s # Optional
144+
# hide_header: [] # Optional list
145+
# ignore_headers: [] # Optional list -- 'X-Accel-Redirect' or 'X-Accel-Charset'
146+
# intercept_errors: false # Optional
147+
# next_upstream: [] # Optional list
148+
# next_upstream_timeout: 0 # Optional
149+
# next_upstream_tries: 0 # Optional
150+
# pass_header: [] # Optional list
151+
# read_timeout: 60s # Optional
152+
# send_timeout: 60s # Optional
153+
# set_header: # Optional
154+
# - field: Accept-Encoding # Required
155+
# value: '""' # Required
156+
# socket_keepalive: false # Optional
157+
# ssl_certificate: fileLocation # Optional
158+
# ssl_certificate_key: fileLocation # Optional
159+
# ssl_ciphers: DEFAULT # Optional
160+
# ssl_conf_command: command # Optional
161+
# ssl_crl: fileLocation # Optional
162+
# ssl_name: serverName # Optional
163+
# ssl_password_file: fileLocation # Optional
164+
# ssl_protocols: [] # Optional list
165+
# ssl_server_name: false # Optional
166+
# ssl_session_reuse: true # Optional
167+
# ssl_trusted_certificate: fileLocation # Optional
168+
# ssl_verify: false # Optional
169+
# ssl_verify_depth: 1 # Optional
99170
ssl:
100171
cert: /etc/ssl/certs/default.crt
101172
key: /etc/ssl/private/default.key
@@ -161,6 +232,40 @@ nginx_config_http_template:
161232
# security_log: # Optional
162233
# path: path # Required
163234
# destination: dest # Required
235+
# grpc_global: # Optional -- Configure GRPC
236+
# bind: # Optional -- Set to 'false' and remove/comment nested variables to disable grpc_bind
237+
# address: $remote_addr # Required
238+
# transparent: true # Optional
239+
# buffer_size: 4k # Optional
240+
# connect_timeout: 60s # Optional
241+
# hide_header: [] # Optional list
242+
# ignore_headers: [] # Optional list -- 'X-Accel-Redirect' or 'X-Accel-Charset'
243+
# intercept_errors: false # Optional
244+
# next_upstream: [] # Optional list
245+
# next_upstream_timeout: 0 # Optional
246+
# next_upstream_tries: 0 # Optional
247+
# pass_header: [] # Optional list
248+
# read_timeout: 60s # Optional
249+
# send_timeout: 60s # Optional
250+
# set_header: # Optional
251+
# - field: Accept-Encoding # Required
252+
# value: '""' # Required
253+
# socket_keepalive: false # Optional
254+
# ssl_certificate: fileLocation # Optional
255+
# ssl_certificate_key: fileLocation # Optional
256+
# ssl_ciphers: DEFAULT # Optional
257+
# ssl_conf_command: command # Optional
258+
# ssl_crl: fileLocation # Optional
259+
# ssl_name: serverName # Optional
260+
# ssl_password_file: fileLocation # Optional
261+
# ssl_protocols: [] # Optional list
262+
# ssl_server_name: false # Optional
263+
# ssl_session_reuse: true # Optional
264+
# ssl_trusted_certificate: fileLocation # Optional
265+
# ssl_verify: false # Optional
266+
# ssl_verify_depth: 1 # Optional
267+
# grpc: # Optional -- Configure GRPC
268+
# pass: localhost:9000 # Optional
164269
include_files: []
165270
proxy_hide_headers: [] # A list of headers which shouldn't be passed to the application
166271
add_headers:
@@ -361,7 +466,7 @@ nginx_config_status_enable: false
361466
nginx_config_status_template_file: http/status.conf.j2
362467
nginx_config_status_file_location: /etc/nginx/conf.d/status.conf
363468
nginx_config_status_port: 8080 # Optional -- Defaults to 8080
364-
nginx_config_status_access_log: # Optional -- Set to 'false' to disable access log
469+
nginx_config_status_access_log: # Optional -- Set to 'false' and remove/comment nested variables to disable access log
365470
location: /var/log/nginx/access.log # Required
366471
name: main # Required
367472
nginx_config_status_allow: # Optional
@@ -377,7 +482,7 @@ nginx_config_rest_api_template_file: http/api.conf.j2
377482
nginx_config_rest_api_file_location: /etc/nginx/conf.d/api.conf
378483
nginx_config_rest_api_port: 8080 # Optional-- Defaults to 8080
379484
nginx_config_rest_api_write: false # Optional
380-
nginx_config_rest_api_access_log: # Optional -- Set to 'false' to disable access log
485+
nginx_config_rest_api_access_log: # Optional -- Set to 'false' and remove/comment nested variables to disable access log
381486
location: /var/log/nginx/access.log # Required
382487
name: main # Required
383488
nginx_config_rest_api_allow: # Optional

meta/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ galaxy_info:
3030
- name: FreeBSD
3131
versions:
3232
- 11.2
33-
- 12.0
33+
- 12.1
3434
- name: Ubuntu
3535
versions:
3636
- xenial
3737
- bionic
3838
- focal
39+
- groovy
3940
- name: SLES
4041
versions:
4142
- 12
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
roles:
33
- name: nginxinc.nginx
4-
version: 0.18.1
4+
version: 0.19.1
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
roles:
33
- name: nginxinc.nginx
4-
version: 0.18.1
4+
version: 0.19.1
55
- name: nginxinc.nginx_app_protect
6-
version: 0.4.1
6+
version: 0.4.2

molecule/default/converge.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,29 @@
2828
worker_connections: 1024
2929
http_enable: true
3030
http_settings:
31+
grpc_global:
32+
bind:
33+
address: $remote_addr
34+
transparent: false
35+
buffer_size: 4k
36+
connect_timeout: 60s
37+
hide_header:
38+
- X-Accel-Redirect
39+
ignore_headers:
40+
- X-Accel-Redirect
41+
intercept_errors: false
42+
next_upstream:
43+
- timeout
44+
next_upstream_timeout: 0
45+
next_upstream_tries: 0
46+
pass_header:
47+
- X-Accel-Charset
48+
read_timeout: 60s
49+
send_timeout: 60s
50+
set_header:
51+
- field: Accept-Encoding
52+
value: '""'
53+
socket_keepalive: false
3154
default_type: application/octet-stream
3255
access_log_format:
3356
- name: main
@@ -116,6 +139,8 @@
116139
locations:
117140
frontend:
118141
location: /
142+
grpc:
143+
pass: localhost:9000
119144
proxy_hide_headers:
120145
- X-Powered-By
121146
add_headers:

templates/http/default.conf.j2

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,16 @@ server {
8585
server_name {{ item.value.servers[server].server_name | default('localhost') }};
8686
{% if item.value.servers[server].app_protect is defined %}
8787
{% from 'app_protect.j2' import app_protect_local with context %}
88-
{% filter indent(8) %}
88+
{% filter indent(4) %}
8989
{{ app_protect_local(item.value.servers[server].app_protect) }}
9090
{% endfilter %}
9191
{% endif %}
92+
{% if item.value.servers[server].grpc_global is defined %}
93+
{% from 'http/grpc.j2' import grpc_global with context %}
94+
{% filter indent(4) %}
95+
{{ grpc_global(item.value.servers[server].grpc_global) }}
96+
{% endfilter %}
97+
{% endif %}
9298
{% if item.value.servers[server].ssl is defined and item.value.servers[server].ssl %}
9399
ssl_certificate {{ item.value.servers[server].ssl.cert }};
94100
ssl_certificate_key {{ item.value.servers[server].ssl.key }};
@@ -199,8 +205,20 @@ server {
199205
{% endif %}
200206
{% if item.value.servers[server].reverse_proxy.locations[location].app_protect is defined %}
201207
{% from 'app_protect.j2' import app_protect_local with context %}
202-
{% filter indent(12) %}
203-
{{ app_protect_local(item.value.servers[server].reverse_proxy.locations[location].app_protect) }}
208+
{% filter indent(8) %}
209+
{{ app_protect_local(item.value.servers[server].reverse_proxy.locations[location].app_protect) }}
210+
{% endfilter %}
211+
{% endif %}
212+
{% if item.value.servers[server].reverse_proxy.locations[location].grpc_global is defined %}
213+
{% from 'http/grpc.j2' import grpc_global with context %}
214+
{% filter indent(8) %}
215+
{{ grpc_global(item.value.servers[server].reverse_proxy.locations[location].grpc_global) }}
216+
{% endfilter %}
217+
{% endif %}
218+
{% if item.value.servers[server].reverse_proxy.locations[location].grpc is defined %}
219+
{% from 'http/grpc.j2' import grpc_local with context %}
220+
{% filter indent(8) %}
221+
{{ grpc_local(item.value.servers[server].reverse_proxy.locations[location].grpc) }}
204222
{% endfilter %}
205223
{% endif %}
206224
{% if item.value.servers[server].reverse_proxy.locations[location].include_files is defined and item.value.servers[server].reverse_proxy.locations[location].include_files | length %}

0 commit comments

Comments
 (0)