Skip to content

Commit a236c73

Browse files
changyyalessfg
authored andcommitted
Add custom_options (#167)
1 parent 1c9a127 commit a236c73

File tree

6 files changed

+95
-2
lines changed

6 files changed

+95
-2
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,10 @@ nginx_main_template:
355355
cache: false
356356
rate_limit: false
357357
keyval: false
358-
stream_enable: false
359358
http_global_autoindex: false
359+
#http_custom_options: []
360+
stream_enable: false
361+
#stream_custom_options: []
360362
#auth_request_http: /auth
361363
#auth_request_set_http:
362364
#name: $auth_user
@@ -449,6 +451,7 @@ nginx_http_template:
449451
#return302:
450452
#code: 302
451453
#url: https://sso.somehost.local/?url=https://$http_host$request_uri
454+
#custom_options: []
452455
http_demo_conf: false
453456
reverse_proxy:
454457
proxy_cache_path:
@@ -556,6 +559,7 @@ nginx_http_template:
556559
#return302:
557560
#code: 302
558561
#url: https://sso.somehost.local/?url=https://$http_host$request_uri
562+
#custom_options: []
559563
health_check_plus: false
560564
proxy_cache:
561565
proxy_cache_path:
@@ -578,11 +582,14 @@ nginx_http_template:
578582
port: 8081
579583
weight: 1
580584
health_check: max_fails=1 fail_timeout=10s
585+
#custom_options: []
581586
returns:
582587
return301:
583588
location: /
584589
code: 301
585590
value: http://$host$request_uri
591+
#http_custom_options: []
592+
#server_custom_options: []
586593

587594
# Enable NGINX status data.
588595
# Will enable 'stub_status' in NGINX Open Source and 'status' in NGINX Plus.
@@ -629,6 +636,7 @@ nginx_stream_template:
629636
verify_depth: 1
630637
session_reuse: true
631638
health_check_plus: false
639+
#custom_options: []
632640
upstreams:
633641
upstream1:
634642
name: backend
@@ -642,6 +650,8 @@ nginx_stream_template:
642650
port: 8080
643651
weight: 1
644652
health_check: max_fails=1 fail_timeout=10s
653+
#custom_options: []
654+
#custom_options: []
645655
```
646656

647657
Dependencies

defaults/main.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,10 @@ nginx_main_template:
166166
cache: false
167167
rate_limit: false
168168
keyval: false
169-
stream_enable: false
170169
http_global_autoindex: false
170+
#http_custom_options: []
171+
stream_enable: false
172+
#stream_custom_options: []
171173
#auth_request_http: /auth
172174
#auth_request_set_http:
173175
#name: $auth_user
@@ -260,6 +262,7 @@ nginx_http_template:
260262
#return302:
261263
#code: 302
262264
#url: https://sso.somehost.local/?url=https://$http_host$request_uri
265+
#custom_options: []
263266
http_demo_conf: false
264267
reverse_proxy:
265268
proxy_cache_path:
@@ -367,6 +370,7 @@ nginx_http_template:
367370
#return302:
368371
#code: 302
369372
#url: https://sso.somehost.local/?url=https://$http_host$request_uri
373+
#custom_options: []
370374
health_check_plus: false
371375
proxy_cache:
372376
proxy_cache_path:
@@ -389,11 +393,14 @@ nginx_http_template:
389393
port: 8081
390394
weight: 1
391395
health_check: max_fails=1 fail_timeout=10s
396+
#custom_options: []
392397
returns:
393398
return301:
394399
location: /
395400
code: 301
396401
value: http://$host$request_uri
402+
#http_custom_options: []
403+
#server_custom_options: []
397404

398405
# Enable NGINX status data.
399406
# Will enable 'stub_status' in NGINX Open Source and 'status' in NGINX Plus.
@@ -440,6 +447,7 @@ nginx_stream_template:
440447
verify_depth: 1
441448
session_reuse: true
442449
health_check_plus: false
450+
#custom_options: []
443451
upstreams:
444452
upstream1:
445453
name: backend
@@ -453,3 +461,5 @@ nginx_stream_template:
453461
port: 8080
454462
weight: 1
455463
health_check: max_fails=1 fail_timeout=10s
464+
#custom_options: []
465+
#custom_options: []

molecule/template_module/playbook.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,16 @@
227227
html_file_location: /usr/share/nginx/html
228228
html_file_name: backend_index.html
229229
autoindex: false
230+
php:
231+
location: ~ \.php$
232+
html_file_location: /usr/share/nginx/html
233+
autoindex: false
234+
custom_options:
235+
- fastcgi_split_path_info ^(.+\.php)(/.+)$
236+
- fastcgi_pass unix:/run/php/php7.2-fpm.sock
237+
- fastcgi_index index.php
238+
- include fastcgi_params
239+
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name
230240
http_demo_conf: true
231241
nginx_html_demo_template_enable: true
232242
nginx_html_demo_template:

templates/http/default.conf.j2

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ upstream {{ item.value.upstreams[upstream].name }} {
1111
{% if item.value.upstreams[upstream].sticky_cookie %}
1212
sticky cookie srv_id expires=1h path=/;
1313
{% endif %}
14+
{% if item.value.upstreams[upstream].custom_options is defined and item.value.upstreams[upstream].custom_options | length %}
15+
{% for inline_option in item.value.upstreams[upstream].custom_options %}
16+
{{ inline_option }};
17+
{% endfor %}
18+
{% endif %}
1419
}
1520
{% endfor %}
1621
{% endif %}
@@ -52,6 +57,12 @@ auth_request {{ item.value.auth_request_http }};
5257
auth_request_set {{ item.value.auth_request_set_http.name }} {{ item.value.auth_request_set_http.value }};
5358
{% endif %}
5459

60+
{% if item.value.http_custom_options is defined and item.value.http_custom_options | length %}
61+
{% for inline_option in item.value.http_custom_options %}
62+
{{ inline_option }};
63+
{% endfor %}
64+
{% endif %}
65+
5566
server {
5667
{% for listen in item.value.listen %}
5768
listen {% if item.value.listen[listen].ip is defined and item.value.listen[listen].ip | length %}{{ item.value.listen[listen].ip }}:{% endif %}{{ item.value.listen[listen].port }}{% if item.value.ssl is defined and item.value.ssl %} ssl{% endif %}{% if item.value.listen[listen].opts is defined and item.value.listen[listen].opts | length %} {{ item.value.listen[listen].opts | join(" ") }}{% endif %};
@@ -133,6 +144,11 @@ server {
133144
{% if item.value.client_max_body_size is defined and item.value.client_max_body_size %}
134145
client_max_body_size {{ item.value.client_max_body_size }};
135146
{% endif %}
147+
{% if item.value.server_custom_options is defined and item.value.server_custom_options | length %}
148+
{% for inline_option in item.value.server_custom_options %}
149+
{{ inline_option }};
150+
{% endfor %}
151+
{% endif %}
136152

137153
{% if item.value.reverse_proxy is defined and item.value.reverse_proxy %}
138154
{% for location in item.value.reverse_proxy.locations %}
@@ -289,6 +305,11 @@ server {
289305
{% if item.value.reverse_proxy.locations[location].proxy_buffering is defined %}
290306
proxy_buffering {{ item.value.reverse_proxy.locations[location].proxy_buffering | ternary("on", "off") }};
291307
{% endif %}
308+
{% if item.value.reverse_proxy.locations[location].custom_options is defined and item.value.reverse_proxy.locations[location].custom_options | length %}
309+
{% for inline_option in item.value.reverse_proxy.locations[location].custom_options %}
310+
{{ inline_option }};
311+
{% endfor %}
312+
{% endif %}
292313
{% if (item.value.reverse_proxy.health_check_plus is defined) and item.value.reverse_proxy.health_check_plus %}
293314
health_check;
294315
{% endif %}
@@ -317,6 +338,11 @@ server {
317338
include "{{ file }}";
318339
{% endfor %}
319340
{% endif %}
341+
{% if item.value.web_server.locations[location].custom_options is defined and item.value.web_server.locations[location].custom_options | length %}
342+
{% for inline_option in item.value.web_server.locations[location].custom_options %}
343+
{{ inline_option }};
344+
{% endfor %}
345+
{% endif %}
320346
{% if item.value.web_server.locations[location].proxy_hide_headers is defined %}
321347
{% for header in item.value.web_server.locations[location].proxy_hide_headers %}
322348
proxy_hide_header {{ header }};

templates/nginx.conf.j2

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,23 @@ worker_processes {{ nginx_main_template.worker_processes }};
3838
worker_rlimit_nofile {{ nginx_main_template.worker_rlimit_nofile }};
3939
{% endif %}
4040

41+
{% if nginx_main_template.custom_options is defined and nginx_main_template.custom_options | length %}
42+
{% for inline_option in nginx_main_template.custom_options %}
43+
{{ inline_option }};
44+
{% endfor %}
45+
{% endif %}
46+
4147
error_log {{ nginx_main_template.error_log.location }} {{ nginx_main_template.error_log.level }};
4248
pid /var/run/nginx.pid;
4349

4450

4551
events {
4652
worker_connections {{ nginx_main_template.worker_connections }};
53+
{% if nginx_main_template.events_custom_options is defined and nginx_main_template.events_custom_options | length %}
54+
{% for inline_option in nginx_main_template.events_custom_options %}
55+
{{ inline_option }};
56+
{% endfor %}
57+
{% endif %}
4758
}
4859

4960
{% if nginx_main_template.http_enable %}
@@ -77,13 +88,23 @@ http {
7788
{% endif %}
7889
{% if nginx_main_template.http_global_autoindex | default(false) %}
7990
autoindex on;
91+
{% endif %}
92+
{% if nginx_main_template.http_custom_options is defined and nginx_main_template.http_custom_options | length %}
93+
{% for inline_option in nginx_main_template.http_custom_options %}
94+
{{ inline_option }};
95+
{% endfor %}
8096
{% endif %}
8197
include /etc/nginx/conf.d/*.conf;
8298
}
8399
{% endif %}
84100

85101
{% if nginx_main_template.stream_enable %}
86102
stream {
103+
{% if nginx_main_template.stream_custom_options is defined and nginx_main_template.stream_custom_options | length %}
104+
{% for inline_option in nginx_main_template.stream_custom_options %}
105+
{{ inline_option }};
106+
{% endfor %}
107+
{% endif %}
87108
include /etc/nginx/conf.d/stream/*.conf;
88109
}
89110
{% endif %}

templates/stream/default.conf.j2

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,21 @@ upstream {{ item.value.upstreams[upstream].name }} {
1515
sticky cookie srv_id expires=1h path=/;
1616
{% endif %}
1717
{% endif %}
18+
{% if item.value.upstreams[upstream].custom_options is defined and item.value.upstreams[upstream].custom_options | length %}
19+
{% for inline_option in item.value.upstreams[upstream].custom_options %}
20+
{{ inline_option }};
21+
{% endfor %}
22+
{% endif %}
1823
}
1924
{% endfor %}
2025
{% endif %}
2126

27+
{% if item.value.custom_options is defined and item.value.custom_options | length %}
28+
{% for inline_option in item.value.custom_options %}
29+
{{ inline_option }};
30+
{% endfor %}
31+
{% endif %}
32+
2233
{% if item.value.network_streams is defined %}
2334
{% for stream in item.value.network_streams %}
2435
server {
@@ -92,6 +103,11 @@ server {
92103
{% if item.value.network_streams[stream].health_check_plus %}
93104
health_check;
94105
{% endif %}
106+
{% if item.value.network_streams[stream].custom_options is defined and item.value.network_streams[stream].custom_options | length %}
107+
{% for inline_option in item.value.network_streams[stream].custom_options %}
108+
{{ inline_option }};
109+
{% endfor %}
110+
{% endif %}
95111
}
96112
{% endfor %}
97113
{% endif %}

0 commit comments

Comments
 (0)