This is an automated email from the ASF dual-hosted git repository.
tokers pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 4aeef38 feat: support more customize configure in nginx.conf (#3204)
4aeef38 is described below
commit 4aeef386f02e7dec38cb86080eadfe16e6115375
Author: shenshaoye <[email protected]>
AuthorDate: Thu Jan 7 19:21:02 2021 +0800
feat: support more customize configure in nginx.conf (#3204)
Co-authored-by: 沈鑫杰 <[email protected]>
related #3203
---
.travis/apisix_cli_test/test_main.sh | 14 ++++++++++++++
apisix/cli/ngx_tpl.lua | 17 +++++++++++------
conf/config-default.yaml | 3 +++
doc/customize-nginx-configuration.md | 2 ++
doc/zh-cn/customize-nginx-configuration.md | 2 ++
5 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/.travis/apisix_cli_test/test_main.sh
b/.travis/apisix_cli_test/test_main.sh
index ab0f890..5983f95 100755
--- a/.travis/apisix_cli_test/test_main.sh
+++ b/.travis/apisix_cli_test/test_main.sh
@@ -675,6 +675,8 @@ nginx_config:
set $my "var";
http_admin_configuration_snippet: |
log_format admin "$request_time $pipe";
+ http_end_configuration_snippet: |
+ server_names_hash_bucket_size 128;
stream_configuration_snippet: |
tcp_nodelay off;
' > conf/config.yaml
@@ -705,6 +707,18 @@ if [ ! $? -eq 0 ]; then
exit 1
fi
+grep 'server_names_hash_bucket_size 128;' -A 2 conf/nginx.conf | grep
"configuration snippet ends" > /dev/null
+if [ ! $? -eq 0 ]; then
+ echo "failed: can't inject http end configuration"
+ exit 1
+fi
+
+grep 'server_names_hash_bucket_size 128;' -A 3 conf/nginx.conf | grep "}" >
/dev/null
+if [ ! $? -eq 0 ]; then
+ echo "failed: can't inject http end configuration"
+ exit 1
+fi
+
grep 'tcp_nodelay off;' -A 2 conf/nginx.conf | grep "configuration snippet
ends" > /dev/null
if [ ! $? -eq 0 ]; then
echo "failed: can't inject stream configuration"
diff --git a/apisix/cli/ngx_tpl.lua b/apisix/cli/ngx_tpl.lua
index 3dabcf0..9f496d2 100644
--- a/apisix/cli/ngx_tpl.lua
+++ b/apisix/cli/ngx_tpl.lua
@@ -26,6 +26,12 @@ worker_processes {* worker_processes *};
worker_cpu_affinity auto;
{% end %}
+# main configuration snippet starts
+{% if main_configuration_snippet then %}
+{* main_configuration_snippet *}
+{% end %}
+# main configuration snippet ends
+
error_log {* error_log *} {* error_log_level or "warn" *};
pid logs/nginx.pid;
@@ -48,12 +54,6 @@ env {*name*};
{% end %}
{% end %}
-# main configuration snippet starts
-{% if main_configuration_snippet then %}
-{* main_configuration_snippet *}
-{% end %}
-# main configuration snippet ends
-
{% if stream_proxy then %}
stream {
lua_package_path
"$prefix/deps/share/lua/5.1/?.lua;$prefix/deps/share/lua/5.1/?/init.lua;]=]
@@ -570,5 +570,10 @@ http {
}
{% end %}
}
+ # http end configuration snippet starts
+ {% if http_end_configuration_snippet then %}
+ {* http_end_configuration_snippet *}
+ {% end %}
+ # http end configuration snippet ends
}
]=]
diff --git a/conf/config-default.yaml b/conf/config-default.yaml
index c9c372f..a4cd24e 100644
--- a/conf/config-default.yaml
+++ b/conf/config-default.yaml
@@ -152,6 +152,9 @@ nginx_config: # config for render the
template to generate n
http_admin_configuration_snippet: |
# Add custom Nginx admin server configuration to nginx.conf.
# The configuration should be well indented!
+ http_end_configuration_snippet: |
+ # Add custom Nginx http end configuration to nginx.conf.
+ # The configuration should be well indented!
stream_configuration_snippet: |
# Add custom Nginx stream configuration to nginx.conf.
# The configuration should be well indented!
diff --git a/doc/customize-nginx-configuration.md
b/doc/customize-nginx-configuration.md
index d65fd8e..8e660a0 100644
--- a/doc/customize-nginx-configuration.md
+++ b/doc/customize-nginx-configuration.md
@@ -53,6 +53,8 @@ nginx_config:
set $my "var";
http_admin_configuration_snippet: |
log_format admin "$request_time $pipe";
+ http_end_configuration_snippet: |
+ server_names_hash_bucket_size 128;
stream_configuration_snippet: |
tcp_nodelay off;
...
diff --git a/doc/zh-cn/customize-nginx-configuration.md
b/doc/zh-cn/customize-nginx-configuration.md
index 5b34f19..e1d0a08 100644
--- a/doc/zh-cn/customize-nginx-configuration.md
+++ b/doc/zh-cn/customize-nginx-configuration.md
@@ -53,6 +53,8 @@ nginx_config:
set $my "var";
http_admin_configuration_snippet: |
log_format admin "$request_time $pipe";
+ http_end_configuration_snippet: |
+ server_names_hash_bucket_size 128;
stream_configuration_snippet: |
tcp_nodelay off;
...