Skip to content

Commit

Permalink
feat: add http_server_location_configuration_snippet configuration (#…
Browse files Browse the repository at this point in the history
…5740)

Co-authored-by: lunhaiz <lunhaiz@rings.net.cn>
  • Loading branch information
zlhgo and zlhgo authored Dec 9, 2021
1 parent 6d3b06b commit 87f6626
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apisix/cli/ngx_tpl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,12 @@ http {
set $ctx_ref '';
set $from_error_page '';
# http server location configuration snippet starts
{% if http_server_location_configuration_snippet then %}
{* http_server_location_configuration_snippet *}
{% end %}
# http server location configuration snippet ends
{% if enabled_plugins["dubbo-proxy"] then %}
set $dubbo_service_name '';
set $dubbo_service_version '';
Expand Down
3 changes: 3 additions & 0 deletions conf/config-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ nginx_config: # config for render the template to generate n
http_server_configuration_snippet: |
# Add custom Nginx http server configuration to nginx.conf.
# The configuration should be well indented!
http_server_location_configuration_snippet: |
# Add custom Nginx http server location configuration to nginx.conf.
# The configuration should be well indented!
http_admin_configuration_snippet: |
# Add custom Nginx admin server configuration to nginx.conf.
# The configuration should be well indented!
Expand Down
8 changes: 8 additions & 0 deletions t/cli/test_snippet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ nginx_config:
chunked_transfer_encoding on;
http_server_configuration_snippet: |
set $my "var";
http_server_location_configuration_snippet: |
set $upstream_name -;
http_admin_configuration_snippet: |
log_format admin "$request_time $pipe";
http_end_configuration_snippet: |
Expand Down Expand Up @@ -65,6 +67,12 @@ if [ ! $? -eq 0 ]; then
exit 1
fi

grep 'set $upstream_name -;' -A 2 conf/nginx.conf | grep "configuration snippet ends" > /dev/null
if [ ! $? -eq 0 ]; then
echo "failed: can't inject http server location configuration"
exit 1
fi

grep 'log_format admin "$request_time $pipe";' -A 2 conf/nginx.conf | grep "configuration snippet ends" > /dev/null
if [ ! $? -eq 0 ]; then
echo "failed: can't inject admin server configuration"
Expand Down

0 comments on commit 87f6626

Please sign in to comment.