This is an automated email from the ASF dual-hosted git repository.

spacewander 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 53e2d53  fix: remove upstream 'Server' header info. fix #2714 (#2731)
53e2d53 is described below

commit 53e2d5387f86d7b36673e75eba6bc58f3a59fb7d
Author: Yousa <snowfly1...@gmail.com>
AuthorDate: Wed Nov 18 13:15:31 2020 +0800

    fix: remove upstream 'Server' header info. fix #2714 (#2731)
    
    fix #2714
---
 apisix/cli/ngx_tpl.lua     | 1 -
 apisix/init.lua            | 4 ++--
 t/APISIX.pm                | 1 -
 t/core/utils.t             | 1 -
 t/node/remote-addr-ipv6.t  | 1 -
 t/plugin/redirect.t        | 1 -
 t/router/multi-ssl-certs.t | 1 -
 t/router/radixtree-sni.t   | 3 ---
 8 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/apisix/cli/ngx_tpl.lua b/apisix/cli/ngx_tpl.lua
index d66b84e..0af266d 100644
--- a/apisix/cli/ngx_tpl.lua
+++ b/apisix/cli/ngx_tpl.lua
@@ -403,7 +403,6 @@ http {
             proxy_set_header   Upgrade           $upstream_upgrade;
             proxy_set_header   Connection        $upstream_connection;
             proxy_set_header   X-Real-IP         $remote_addr;
-            proxy_pass_header  Server;
             proxy_pass_header  Date;
 
             ### the following x-forwarded-* headers is to send to upstream 
server
diff --git a/apisix/init.lua b/apisix/init.lua
index b591e36..629e750 100644
--- a/apisix/init.lua
+++ b/apisix/init.lua
@@ -338,8 +338,6 @@ function _M.http_access_phase()
 
     core.ctx.set_vars_meta(api_ctx)
 
-    core.response.set_header("Server", ver_header)
-
     -- load and run global rule
     if router.global_rules and router.global_rules.values
        and #router.global_rules.values > 0 then
@@ -629,6 +627,8 @@ end
 
 
 function _M.http_header_filter_phase()
+    core.response.set_header("Server", ver_header)
+
     common_phase("header_filter")
 end
 
diff --git a/t/APISIX.pm b/t/APISIX.pm
index 43de420..ca47f3b 100644
--- a/t/APISIX.pm
+++ b/t/APISIX.pm
@@ -399,7 +399,6 @@ _EOC_
             proxy_set_header   Upgrade           \$upstream_upgrade;
             proxy_set_header   Connection        \$upstream_connection;
             proxy_set_header   X-Real-IP         \$remote_addr;
-            proxy_pass_header  Server;
             proxy_pass_header  Date;
             proxy_pass         
\$upstream_scheme://apisix_backend\$upstream_uri;
             mirror             /proxy_mirror;
diff --git a/t/core/utils.t b/t/core/utils.t
index 6fb4240..402ae4e 100644
--- a/t/core/utils.t
+++ b/t/core/utils.t
@@ -195,7 +195,6 @@ received: Content-Type: text/plain
 received: Content-Length: 12
 received: Connection: close
 received: Server: APISIX
-received: Server: openresty
 received: \nreceived: hello world
 close: 1 nil}
 --- no_error_log
diff --git a/t/node/remote-addr-ipv6.t b/t/node/remote-addr-ipv6.t
index 9861275..2e610fe 100644
--- a/t/node/remote-addr-ipv6.t
+++ b/t/node/remote-addr-ipv6.t
@@ -116,7 +116,6 @@ received: Content-Type: text/plain
 received: Content-Length: 12
 received: Connection: close
 received: Server: APISIX/\d\.\d+(\.\d+)?
-received: Server: \w+
 received: 
 received: hello world
 failed to receive a line: closed \[\]
diff --git a/t/plugin/redirect.t b/t/plugin/redirect.t
index 45dcb1e..daee190 100644
--- a/t/plugin/redirect.t
+++ b/t/plugin/redirect.t
@@ -671,7 +671,6 @@ received: Content-Type: text/plain
 received: Content-Length: 12
 received: Connection: close
 received: Server: APISIX/\d\.\d+(\.\d+)?
-received: Server: \w+
 received: \nreceived: hello world
 close: 1 nil}
 --- no_error_log
diff --git a/t/router/multi-ssl-certs.t b/t/router/multi-ssl-certs.t
index 6990ad9..ea092aa 100644
--- a/t/router/multi-ssl-certs.t
+++ b/t/router/multi-ssl-certs.t
@@ -162,7 +162,6 @@ received: Content-Type: text/plain
 received: Content-Length: 12
 received: Connection: close
 received: Server: APISIX/\d\.\d+(\.\d+)?
-received: Server: \w+
 received: \nreceived: hello world
 close: 1 nil}
 --- error_log
diff --git a/t/router/radixtree-sni.t b/t/router/radixtree-sni.t
index 88d3da6..532fdea 100644
--- a/t/router/radixtree-sni.t
+++ b/t/router/radixtree-sni.t
@@ -162,7 +162,6 @@ received: Content-Type: text/plain
 received: Content-Length: 12
 received: Connection: close
 received: Server: APISIX/\d\.\d+(\.\d+)?
-received: Server: \w+
 received: \nreceived: hello world
 close: 1 nil}
 --- error_log
@@ -317,7 +316,6 @@ received: Content-Type: text/plain
 received: Content-Length: 12
 received: Connection: close
 received: Server: APISIX/\d\.\d+(\.\d+)?
-received: Server: \w+
 received: \nreceived: hello world
 close: 1 nil}
 --- error_log
@@ -432,7 +430,6 @@ received: Content-Type: text/plain
 received: Content-Length: 12
 received: Connection: close
 received: Server: APISIX/\d\.\d+(\.\d+)?
-received: Server: \w+
 received: \nreceived: hello world
 close: 1 nil}
 --- error_log

Reply via email to