Add custom_options (#167)

This commit is contained in:
Yuan-Yi Chang 2019-10-20 23:52:56 +08:00 committed by Alessandro Fael Garcia
parent 1c9a1278b3
commit a236c73af8
6 changed files with 95 additions and 2 deletions

View File

@ -355,8 +355,10 @@ nginx_main_template:
cache: false cache: false
rate_limit: false rate_limit: false
keyval: false keyval: false
stream_enable: false
http_global_autoindex: false http_global_autoindex: false
#http_custom_options: []
stream_enable: false
#stream_custom_options: []
#auth_request_http: /auth #auth_request_http: /auth
#auth_request_set_http: #auth_request_set_http:
#name: $auth_user #name: $auth_user
@ -449,6 +451,7 @@ nginx_http_template:
#return302: #return302:
#code: 302 #code: 302
#url: https://sso.somehost.local/?url=https://$http_host$request_uri #url: https://sso.somehost.local/?url=https://$http_host$request_uri
#custom_options: []
http_demo_conf: false http_demo_conf: false
reverse_proxy: reverse_proxy:
proxy_cache_path: proxy_cache_path:
@ -556,6 +559,7 @@ nginx_http_template:
#return302: #return302:
#code: 302 #code: 302
#url: https://sso.somehost.local/?url=https://$http_host$request_uri #url: https://sso.somehost.local/?url=https://$http_host$request_uri
#custom_options: []
health_check_plus: false health_check_plus: false
proxy_cache: proxy_cache:
proxy_cache_path: proxy_cache_path:
@ -578,11 +582,14 @@ nginx_http_template:
port: 8081 port: 8081
weight: 1 weight: 1
health_check: max_fails=1 fail_timeout=10s health_check: max_fails=1 fail_timeout=10s
#custom_options: []
returns: returns:
return301: return301:
location: / location: /
code: 301 code: 301
value: http://$host$request_uri value: http://$host$request_uri
#http_custom_options: []
#server_custom_options: []
# Enable NGINX status data. # Enable NGINX status data.
# Will enable 'stub_status' in NGINX Open Source and 'status' in NGINX Plus. # Will enable 'stub_status' in NGINX Open Source and 'status' in NGINX Plus.
@ -629,6 +636,7 @@ nginx_stream_template:
verify_depth: 1 verify_depth: 1
session_reuse: true session_reuse: true
health_check_plus: false health_check_plus: false
#custom_options: []
upstreams: upstreams:
upstream1: upstream1:
name: backend name: backend
@ -642,6 +650,8 @@ nginx_stream_template:
port: 8080 port: 8080
weight: 1 weight: 1
health_check: max_fails=1 fail_timeout=10s health_check: max_fails=1 fail_timeout=10s
#custom_options: []
#custom_options: []
``` ```
Dependencies Dependencies

View File

@ -166,8 +166,10 @@ nginx_main_template:
cache: false cache: false
rate_limit: false rate_limit: false
keyval: false keyval: false
stream_enable: false
http_global_autoindex: false http_global_autoindex: false
#http_custom_options: []
stream_enable: false
#stream_custom_options: []
#auth_request_http: /auth #auth_request_http: /auth
#auth_request_set_http: #auth_request_set_http:
#name: $auth_user #name: $auth_user
@ -260,6 +262,7 @@ nginx_http_template:
#return302: #return302:
#code: 302 #code: 302
#url: https://sso.somehost.local/?url=https://$http_host$request_uri #url: https://sso.somehost.local/?url=https://$http_host$request_uri
#custom_options: []
http_demo_conf: false http_demo_conf: false
reverse_proxy: reverse_proxy:
proxy_cache_path: proxy_cache_path:
@ -367,6 +370,7 @@ nginx_http_template:
#return302: #return302:
#code: 302 #code: 302
#url: https://sso.somehost.local/?url=https://$http_host$request_uri #url: https://sso.somehost.local/?url=https://$http_host$request_uri
#custom_options: []
health_check_plus: false health_check_plus: false
proxy_cache: proxy_cache:
proxy_cache_path: proxy_cache_path:
@ -389,11 +393,14 @@ nginx_http_template:
port: 8081 port: 8081
weight: 1 weight: 1
health_check: max_fails=1 fail_timeout=10s health_check: max_fails=1 fail_timeout=10s
#custom_options: []
returns: returns:
return301: return301:
location: / location: /
code: 301 code: 301
value: http://$host$request_uri value: http://$host$request_uri
#http_custom_options: []
#server_custom_options: []
# Enable NGINX status data. # Enable NGINX status data.
# Will enable 'stub_status' in NGINX Open Source and 'status' in NGINX Plus. # Will enable 'stub_status' in NGINX Open Source and 'status' in NGINX Plus.
@ -440,6 +447,7 @@ nginx_stream_template:
verify_depth: 1 verify_depth: 1
session_reuse: true session_reuse: true
health_check_plus: false health_check_plus: false
#custom_options: []
upstreams: upstreams:
upstream1: upstream1:
name: backend name: backend
@ -453,3 +461,5 @@ nginx_stream_template:
port: 8080 port: 8080
weight: 1 weight: 1
health_check: max_fails=1 fail_timeout=10s health_check: max_fails=1 fail_timeout=10s
#custom_options: []
#custom_options: []

View File

@ -227,6 +227,16 @@
html_file_location: /usr/share/nginx/html html_file_location: /usr/share/nginx/html
html_file_name: backend_index.html html_file_name: backend_index.html
autoindex: false autoindex: false
php:
location: ~ \.php$
html_file_location: /usr/share/nginx/html
autoindex: false
custom_options:
- fastcgi_split_path_info ^(.+\.php)(/.+)$
- fastcgi_pass unix:/run/php/php7.2-fpm.sock
- fastcgi_index index.php
- include fastcgi_params
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name
http_demo_conf: true http_demo_conf: true
nginx_html_demo_template_enable: true nginx_html_demo_template_enable: true
nginx_html_demo_template: nginx_html_demo_template:

View File

@ -11,6 +11,11 @@ upstream {{ item.value.upstreams[upstream].name }} {
{% if item.value.upstreams[upstream].sticky_cookie %} {% if item.value.upstreams[upstream].sticky_cookie %}
sticky cookie srv_id expires=1h path=/; sticky cookie srv_id expires=1h path=/;
{% endif %} {% endif %}
{% if item.value.upstreams[upstream].custom_options is defined and item.value.upstreams[upstream].custom_options | length %}
{% for inline_option in item.value.upstreams[upstream].custom_options %}
{{ inline_option }};
{% endfor %}
{% endif %}
} }
{% endfor %} {% endfor %}
{% endif %} {% endif %}
@ -52,6 +57,12 @@ auth_request {{ item.value.auth_request_http }};
auth_request_set {{ item.value.auth_request_set_http.name }} {{ item.value.auth_request_set_http.value }}; auth_request_set {{ item.value.auth_request_set_http.name }} {{ item.value.auth_request_set_http.value }};
{% endif %} {% endif %}
{% if item.value.http_custom_options is defined and item.value.http_custom_options | length %}
{% for inline_option in item.value.http_custom_options %}
{{ inline_option }};
{% endfor %}
{% endif %}
server { server {
{% for listen in item.value.listen %} {% for listen in item.value.listen %}
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 %}; 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 {
{% if item.value.client_max_body_size is defined and item.value.client_max_body_size %} {% if item.value.client_max_body_size is defined and item.value.client_max_body_size %}
client_max_body_size {{ item.value.client_max_body_size }}; client_max_body_size {{ item.value.client_max_body_size }};
{% endif %} {% endif %}
{% if item.value.server_custom_options is defined and item.value.server_custom_options | length %}
{% for inline_option in item.value.server_custom_options %}
{{ inline_option }};
{% endfor %}
{% endif %}
{% if item.value.reverse_proxy is defined and item.value.reverse_proxy %} {% if item.value.reverse_proxy is defined and item.value.reverse_proxy %}
{% for location in item.value.reverse_proxy.locations %} {% for location in item.value.reverse_proxy.locations %}
@ -289,6 +305,11 @@ server {
{% if item.value.reverse_proxy.locations[location].proxy_buffering is defined %} {% if item.value.reverse_proxy.locations[location].proxy_buffering is defined %}
proxy_buffering {{ item.value.reverse_proxy.locations[location].proxy_buffering | ternary("on", "off") }}; proxy_buffering {{ item.value.reverse_proxy.locations[location].proxy_buffering | ternary("on", "off") }};
{% endif %} {% endif %}
{% if item.value.reverse_proxy.locations[location].custom_options is defined and item.value.reverse_proxy.locations[location].custom_options | length %}
{% for inline_option in item.value.reverse_proxy.locations[location].custom_options %}
{{ inline_option }};
{% endfor %}
{% endif %}
{% if (item.value.reverse_proxy.health_check_plus is defined) and item.value.reverse_proxy.health_check_plus %} {% if (item.value.reverse_proxy.health_check_plus is defined) and item.value.reverse_proxy.health_check_plus %}
health_check; health_check;
{% endif %} {% endif %}
@ -317,6 +338,11 @@ server {
include "{{ file }}"; include "{{ file }}";
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if item.value.web_server.locations[location].custom_options is defined and item.value.web_server.locations[location].custom_options | length %}
{% for inline_option in item.value.web_server.locations[location].custom_options %}
{{ inline_option }};
{% endfor %}
{% endif %}
{% if item.value.web_server.locations[location].proxy_hide_headers is defined %} {% if item.value.web_server.locations[location].proxy_hide_headers is defined %}
{% for header in item.value.web_server.locations[location].proxy_hide_headers %} {% for header in item.value.web_server.locations[location].proxy_hide_headers %}
proxy_hide_header {{ header }}; proxy_hide_header {{ header }};

View File

@ -38,12 +38,23 @@ worker_processes {{ nginx_main_template.worker_processes }};
worker_rlimit_nofile {{ nginx_main_template.worker_rlimit_nofile }}; worker_rlimit_nofile {{ nginx_main_template.worker_rlimit_nofile }};
{% endif %} {% endif %}
{% if nginx_main_template.custom_options is defined and nginx_main_template.custom_options | length %}
{% for inline_option in nginx_main_template.custom_options %}
{{ inline_option }};
{% endfor %}
{% endif %}
error_log {{ nginx_main_template.error_log.location }} {{ nginx_main_template.error_log.level }}; error_log {{ nginx_main_template.error_log.location }} {{ nginx_main_template.error_log.level }};
pid /var/run/nginx.pid; pid /var/run/nginx.pid;
events { events {
worker_connections {{ nginx_main_template.worker_connections }}; worker_connections {{ nginx_main_template.worker_connections }};
{% if nginx_main_template.events_custom_options is defined and nginx_main_template.events_custom_options | length %}
{% for inline_option in nginx_main_template.events_custom_options %}
{{ inline_option }};
{% endfor %}
{% endif %}
} }
{% if nginx_main_template.http_enable %} {% if nginx_main_template.http_enable %}
@ -77,6 +88,11 @@ http {
{% endif %} {% endif %}
{% if nginx_main_template.http_global_autoindex | default(false) %} {% if nginx_main_template.http_global_autoindex | default(false) %}
autoindex on; autoindex on;
{% endif %}
{% if nginx_main_template.http_custom_options is defined and nginx_main_template.http_custom_options | length %}
{% for inline_option in nginx_main_template.http_custom_options %}
{{ inline_option }};
{% endfor %}
{% endif %} {% endif %}
include /etc/nginx/conf.d/*.conf; include /etc/nginx/conf.d/*.conf;
} }
@ -84,6 +100,11 @@ http {
{% if nginx_main_template.stream_enable %} {% if nginx_main_template.stream_enable %}
stream { stream {
{% if nginx_main_template.stream_custom_options is defined and nginx_main_template.stream_custom_options | length %}
{% for inline_option in nginx_main_template.stream_custom_options %}
{{ inline_option }};
{% endfor %}
{% endif %}
include /etc/nginx/conf.d/stream/*.conf; include /etc/nginx/conf.d/stream/*.conf;
} }
{% endif %} {% endif %}

View File

@ -15,10 +15,21 @@ upstream {{ item.value.upstreams[upstream].name }} {
sticky cookie srv_id expires=1h path=/; sticky cookie srv_id expires=1h path=/;
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if item.value.upstreams[upstream].custom_options is defined and item.value.upstreams[upstream].custom_options | length %}
{% for inline_option in item.value.upstreams[upstream].custom_options %}
{{ inline_option }};
{% endfor %}
{% endif %}
} }
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if item.value.custom_options is defined and item.value.custom_options | length %}
{% for inline_option in item.value.custom_options %}
{{ inline_option }};
{% endfor %}
{% endif %}
{% if item.value.network_streams is defined %} {% if item.value.network_streams is defined %}
{% for stream in item.value.network_streams %} {% for stream in item.value.network_streams %}
server { server {
@ -92,6 +103,11 @@ server {
{% if item.value.network_streams[stream].health_check_plus %} {% if item.value.network_streams[stream].health_check_plus %}
health_check; health_check;
{% endif %} {% endif %}
{% if item.value.network_streams[stream].custom_options is defined and item.value.network_streams[stream].custom_options | length %}
{% for inline_option in item.value.network_streams[stream].custom_options %}
{{ inline_option }};
{% endfor %}
{% endif %}
} }
{% endfor %} {% endfor %}
{% endif %} {% endif %}