diff --git a/apisix/cli/ngx_tpl.lua b/apisix/cli/ngx_tpl.lua index 8de3bd1a1309..71c3e80c3642 100644 --- a/apisix/cli/ngx_tpl.lua +++ b/apisix/cli/ngx_tpl.lua @@ -217,7 +217,7 @@ http { server_tokens off; include mime.types; - charset utf-8; + charset {* http.charset *}; # error_page error_page 500 @50x.html; diff --git a/conf/config-default.yaml b/conf/config-default.yaml index a48f91611048..fbccd79ae3ab 100644 --- a/conf/config-default.yaml +++ b/conf/config-default.yaml @@ -195,6 +195,8 @@ nginx_config: # config for render the template to generate n keepalive_requests: 1000 # Sets the maximum number of requests that can be served through one keepalive connection. # After the maximum number of requests is made, the connection is closed. keepalive_timeout: 60s # Sets a timeout during which an idle keepalive connection to an upstream server will stay open. + charset: utf-8 # Adds the specified charset to the "Content-Type" response header field, see + # http://nginx.org/en/docs/http/ngx_http_charset_module.html#charset etcd: host: # it's possible to define multiple etcd hosts addresses of the same etcd cluster. diff --git a/t/cli/test_main.sh b/t/cli/test_main.sh index 9be93f029edf..0c01a7ee46bc 100755 --- a/t/cli/test_main.sh +++ b/t/cli/test_main.sh @@ -621,3 +621,21 @@ if ! grep "keepalive_timeout 6s;" conf/nginx.conf > /dev/null; then fi echo "passed: found the keepalive related parameter in nginx.conf" + +# check the charset setting +git checkout conf/config.yaml + +echo ' +nginx_config: + http: + charset: gbk +' > conf/config.yaml + +make init + +if ! grep "charset gbk;" conf/nginx.conf > /dev/null; then + echo "failed: 'charset gbk;' not in nginx.conf" + exit 1 +fi + +echo "passed: found the 'charset gbk;' in nginx.conf"