This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch release/2.10
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/release/2.10 by this push:
new d4e658f feat: release 2.10.4 (#6255)
d4e658f is described below
commit d4e658fed1fb998e3301597f663a7fa9cd1d15c3
Author: Zeping Bai <[email protected]>
AuthorDate: Mon Feb 7 17:41:50 2022 +0800
feat: release 2.10.4 (#6255)
Co-authored-by: 罗泽轩 <[email protected]>
---
CHANGELOG.md | 7 ++
apisix/core/version.lua | 2 +-
apisix/plugins/batch-requests.lua | 2 +
docs/en/latest/config.json | 2 +-
docs/en/latest/how-to-build.md | 14 ++--
docs/zh/latest/CHANGELOG.md | 7 ++
docs/zh/latest/config.json | 2 +-
docs/zh/latest/how-to-build.md | 14 ++--
rockspec/apisix-2.10.4-0.rockspec | 95 ++++++++++++++++++++++++
t/plugin/batch-requests2.t | 151 ++++++++++++++++++++++++++++++++++++++
10 files changed, 279 insertions(+), 17 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a6edb03..cff0d88 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,7 @@ title: Changelog
## Table of Contents
+- [2.10.4](#2104)
- [2.10.3](#2103)
- [2.10.2](#2102)
- [2.10.1](#2101)
@@ -49,6 +50,12 @@ title: Changelog
- [0.7.0](#070)
- [0.6.0](#060)
+## 2.10.4
+
+### Bugfix
+
+- fix(batch-requests): real ip header should be overridden
[#6251](https://github.com/apache/apisix/pull/6251)
+
## 2.10.3
### Bugfix
diff --git a/apisix/core/version.lua b/apisix/core/version.lua
index 92f3f15..2b1c5b2 100644
--- a/apisix/core/version.lua
+++ b/apisix/core/version.lua
@@ -15,5 +15,5 @@
-- limitations under the License.
--
return {
- VERSION = "2.10.3"
+ VERSION = "2.10.4"
}
diff --git a/apisix/plugins/batch-requests.lua
b/apisix/plugins/batch-requests.lua
index 71a3752..54dfba0 100644
--- a/apisix/plugins/batch-requests.lua
+++ b/apisix/plugins/batch-requests.lua
@@ -165,6 +165,8 @@ local function set_common_header(data)
local local_conf = core.config.local_conf()
local real_ip_hdr = core.table.try_read_attr(local_conf, "nginx_config",
"http",
"real_ip_header")
+ -- we don't need to handle '_' to '-' as Nginx won't treat 'X_REAL_IP' as
'X-Real-IP'
+ real_ip_hdr = str_lower(real_ip_hdr)
local outer_headers = core.request.headers(nil)
for i,req in ipairs(data.pipeline) do
diff --git a/docs/en/latest/config.json b/docs/en/latest/config.json
index cfc1759..ccce56f 100644
--- a/docs/en/latest/config.json
+++ b/docs/en/latest/config.json
@@ -1,5 +1,5 @@
{
- "version": "2.10.3",
+ "version": "2.10.4",
"sidebar": [
{
"type": "category",
diff --git a/docs/en/latest/how-to-build.md b/docs/en/latest/how-to-build.md
index 2a45f0a..bc31fad 100644
--- a/docs/en/latest/how-to-build.md
+++ b/docs/en/latest/how-to-build.md
@@ -58,7 +58,7 @@ sudo yum install -y
https://repos.apiseven.com/packages/centos/apache-apisix-rep
This installation method is suitable for CentOS 7, please run the following
command to install Apache APISIX.
```shell
-sudo yum install -y
https://repos.apiseven.com/packages/centos/7/x86_64/apisix-2.10.3-0.el7.x86_64.rpm
+sudo yum install -y
https://repos.apiseven.com/packages/centos/7/x86_64/apisix-2.10.4-0.el7.x86_64.rpm
```
### Installation via Docker
@@ -71,16 +71,16 @@ Please refer to: [Installing Apache APISIX with Helm
Chart](https://github.com/a
### Installation via Source Release Package
-1. Create a directory named `apisix-2.10.3`.
+1. Create a directory named `apisix-2.10.4`.
```shell
- mkdir apisix-2.10.3
+ mkdir apisix-2.10.4
```
2. Download Apache APISIX Release source package.
```shell
- wget https://downloads.apache.org/apisix/2.10.3/apache-apisix-2.10.3-src.tgz
+ wget https://downloads.apache.org/apisix/2.10.4/apache-apisix-2.10.4-src.tgz
```
You can also download the Apache APISIX Release source package from the
Apache APISIX website. The [Apache APISIX Official Website - Download
Page](https://apisix.apache.org/downloads/) also provides source packages for
Apache APISIX, APISIX Dashboard and APISIX Ingress Controller.
@@ -88,14 +88,14 @@ Please refer to: [Installing Apache APISIX with Helm
Chart](https://github.com/a
3. Unzip the Apache APISIX Release source package.
```shell
- tar zxvf apache-apisix-2.10.3-src.tgz -C apisix-2.10.3
+ tar zxvf apache-apisix-2.10.4-src.tgz -C apisix-2.10.4
```
4. Install the runtime dependent Lua libraries.
```shell
- # Switch to the apisix-2.10.3 directory
- cd apisix-2.10.3
+ # Switch to the apisix-2.10.4 directory
+ cd apisix-2.10.4
# Create dependencies
make deps
# Install apisix command
diff --git a/docs/zh/latest/CHANGELOG.md b/docs/zh/latest/CHANGELOG.md
index 1617b4e..c0e696a 100644
--- a/docs/zh/latest/CHANGELOG.md
+++ b/docs/zh/latest/CHANGELOG.md
@@ -23,6 +23,7 @@ title: CHANGELOG
## Table of Contents
+- [2.10.4](#2104)
- [2.10.3](#2103)
- [2.10.2](#2102)
- [2.10.1](#2101)
@@ -49,6 +50,12 @@ title: CHANGELOG
- [0.7.0](#070)
- [0.6.0](#060)
+## 2.10.4
+
+### Bugfix
+
+- batch-requests 插件应当覆盖 real ip 请求头
[#6251](https://github.com/apache/apisix/pull/6251)
+
## 2.10.3
### Bugfix
diff --git a/docs/zh/latest/config.json b/docs/zh/latest/config.json
index 4203546..7a5fec7 100644
--- a/docs/zh/latest/config.json
+++ b/docs/zh/latest/config.json
@@ -1,5 +1,5 @@
{
- "version": "2.10.3",
+ "version": "2.10.4",
"sidebar": [
{
"type": "category",
diff --git a/docs/zh/latest/how-to-build.md b/docs/zh/latest/how-to-build.md
index 96856d3..7e72630 100644
--- a/docs/zh/latest/how-to-build.md
+++ b/docs/zh/latest/how-to-build.md
@@ -58,7 +58,7 @@ sudo yum install -y
https://repos.apiseven.com/packages/centos/apache-apisix-rep
这种安装方式适用于 CentOS 7 操作系统,请运行以下命令安装 Apache APISIX。
```shell
-sudo yum install -y
https://repos.apiseven.com/packages/centos/7/x86_64/apisix-2.10.3-0.el7.x86_64.rpm
+sudo yum install -y
https://repos.apiseven.com/packages/centos/7/x86_64/apisix-2.10.4-0.el7.x86_64.rpm
```
### 通过 Docker 安装
@@ -71,16 +71,16 @@ sudo yum install -y
https://repos.apiseven.com/packages/centos/7/x86_64/apisix-2
### 通过源码包安装
-1. 创建一个名为 `apisix-2.10.3` 的目录。
+1. 创建一个名为 `apisix-2.10.4` 的目录。
```shell
- mkdir apisix-2.10.3
+ mkdir apisix-2.10.4
```
2. 下载 Apache APISIX Release 源码包:
```shell
- wget https://downloads.apache.org/apisix/2.10.3/apache-apisix-2.10.3-src.tgz
+ wget https://downloads.apache.org/apisix/2.10.4/apache-apisix-2.10.4-src.tgz
```
您也可以通过 Apache APISIX 官网下载 Apache APISIX Release 源码包。 Apache APISIX 官网也提供了
Apache APISIX、APISIX Dashboard 和 APISIX Ingress Controller 的源码包,详情请参考[Apache
APISIX 官网-下载页](https://apisix.apache.org/zh/downloads)。
@@ -88,14 +88,14 @@ sudo yum install -y
https://repos.apiseven.com/packages/centos/7/x86_64/apisix-2
3. 解压 Apache APISIX Release 源码包:
```shell
- tar zxvf apache-apisix-2.10.3-src.tgz -C apisix-2.10.3
+ tar zxvf apache-apisix-2.10.4-src.tgz -C apisix-2.10.4
```
4. 安装运行时依赖的 Lua 库:
```shell
- # 切换到 apisix-2.10.3 目录
- cd apisix-2.10.3
+ # 切换到 apisix-2.10.4 目录
+ cd apisix-2.10.4
# 安装依赖
LUAROCKS_SERVER=https://luarocks.cn make deps
# 安装 apisix 命令
diff --git a/rockspec/apisix-2.10.4-0.rockspec
b/rockspec/apisix-2.10.4-0.rockspec
new file mode 100644
index 0000000..83ddd4a
--- /dev/null
+++ b/rockspec/apisix-2.10.4-0.rockspec
@@ -0,0 +1,95 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+package = "apisix"
+version = "2.10.4-0"
+supported_platforms = {"linux", "macosx"}
+
+source = {
+ url = "git://github.com/apache/apisix",
+ branch = "2.10.4",
+}
+
+description = {
+ summary = "Apache APISIX is a cloud-native microservices API gateway,
delivering the ultimate performance, security, open source and scalable
platform for all your APIs and microservices.",
+ homepage = "https://github.com/apache/apisix",
+ license = "Apache License 2.0",
+}
+
+dependencies = {
+ "lua-resty-ctxdump = 0.1-0",
+ "lua-resty-dns-client = 5.2.0",
+ "lua-resty-template = 2.0",
+ "lua-resty-etcd = 1.5.4",
+ "api7-lua-resty-http = 0.2.0",
+ "lua-resty-balancer = 0.04",
+ "lua-resty-ngxvar = 0.5.2",
+ "lua-resty-jit-uuid = 0.0.7",
+ "lua-resty-healthcheck-api7 = 2.2.0",
+ "lua-resty-jwt = 0.2.0",
+ "lua-resty-hmac-ffi = 0.05",
+ "lua-resty-cookie = 0.1.0",
+ "lua-resty-session = 2.24",
+ "opentracing-openresty = 0.1",
+ "lua-resty-radixtree = 2.8.1",
+ "lua-protobuf = 0.3.3",
+ "lua-resty-openidc = 1.7.2-1",
+ "luafilesystem = 1.7.0-2",
+ "api7-lua-tinyyaml = 0.3.0",
+ "nginx-lua-prometheus = 0.20210206",
+ "jsonschema = 0.9.5",
+ "lua-resty-ipmatcher = 0.6.1",
+ "lua-resty-kafka = 0.07",
+ "lua-resty-logger-socket = 2.0-0",
+ "skywalking-nginx-lua = 0.4-1",
+ "base64 = 1.5-2",
+ "binaryheap = 0.4",
+ "dkjson = 2.5-2",
+ "resty-redis-cluster = 1.02-4",
+ "lua-resty-expr = 1.3.1",
+ "graphql = 0.0.2",
+ "argparse = 0.7.1-1",
+ "luasocket = 3.0rc1-2",
+ "luasec = 0.9-1",
+ "lua-resty-consul = 0.3-2",
+ "penlight = 1.9.2-1",
+ "ext-plugin-proto = 0.3.0",
+ "casbin = 1.26.0",
+ "api7-snowflake = 2.0-1",
+ "inspect == 3.1.1",
+}
+
+build = {
+ type = "make",
+ build_variables = {
+ CFLAGS="$(CFLAGS)",
+ LIBFLAG="$(LIBFLAG)",
+ LUA_LIBDIR="$(LUA_LIBDIR)",
+ LUA_BINDIR="$(LUA_BINDIR)",
+ LUA_INCDIR="$(LUA_INCDIR)",
+ LUA="$(LUA)",
+ OPENSSL_INCDIR="$(OPENSSL_INCDIR)",
+ OPENSSL_LIBDIR="$(OPENSSL_LIBDIR)",
+ },
+ install_variables = {
+ INST_PREFIX="$(PREFIX)",
+ INST_BINDIR="$(BINDIR)",
+ INST_LIBDIR="$(LIBDIR)",
+ INST_LUADIR="$(LUADIR)",
+ INST_CONFDIR="$(CONFDIR)",
+ },
+}
diff --git a/t/plugin/batch-requests2.t b/t/plugin/batch-requests2.t
index ba578c4..c61278d 100644
--- a/t/plugin/batch-requests2.t
+++ b/t/plugin/batch-requests2.t
@@ -224,3 +224,154 @@ plugin_attr:
ngx.status = 200
}
}
+
+
+
+=== TEST 5: ensure real ip header is overridden
+--- config
+ location = /aggregate {
+ content_by_lua_block {
+ local core = require("apisix.core")
+ local t = require("lib.test_admin").test
+ local code, body = t('/apisix/batch-requests',
+ ngx.HTTP_POST,
+ [=[{
+ "headers": {
+ "x-real-ip": "127.0.0.2"
+ },
+ "pipeline":[
+ {
+ "path": "/c",
+ "method": "PUT"
+ }]
+ }]=],
+ [=[[
+ {
+ "status": 201,
+ "body":"C",
+ "headers": {
+ "Client-IP": "127.0.0.1",
+ "Client-IP-From-Hdr": "127.0.0.1"
+ }
+ }
+ ]]=])
+
+ ngx.status = code
+ ngx.say(body)
+ }
+ }
+
+ location = /c {
+ content_by_lua_block {
+ ngx.status = 201
+ ngx.header["Client-IP"] = ngx.var.remote_addr
+ ngx.header["Client-IP-From-Hdr"] =
ngx.req.get_headers()["x-real-ip"]
+ ngx.print("C")
+ }
+ }
+--- request
+GET /aggregate
+--- response_body
+passed
+
+
+
+=== TEST 6: ensure real ip header is overridden, header from the pipeline
+--- config
+ location = /aggregate {
+ content_by_lua_block {
+ local core = require("apisix.core")
+ local t = require("lib.test_admin").test
+ local code, body = t('/apisix/batch-requests',
+ ngx.HTTP_POST,
+ [=[{
+ "headers": {
+ },
+ "pipeline":[
+ {
+ "path": "/c",
+ "headers": {
+ "x-real-ip": "127.0.0.2"
+ },
+ "method": "PUT"
+ }]
+ }]=],
+ [=[[
+ {
+ "status": 201,
+ "body":"C",
+ "headers": {
+ "Client-IP": "127.0.0.1",
+ "Client-IP-From-Hdr": "127.0.0.1"
+ }
+ }
+ ]]=])
+
+ ngx.status = code
+ ngx.say(body)
+ }
+ }
+
+ location = /c {
+ content_by_lua_block {
+ ngx.status = 201
+ ngx.header["Client-IP"] = ngx.var.remote_addr
+ ngx.header["Client-IP-From-Hdr"] =
ngx.req.get_headers()["x-real-ip"]
+ ngx.print("C")
+ }
+ }
+--- request
+GET /aggregate
+--- response_body
+passed
+
+
+
+=== TEST 7: ensure real ip header is overridden, header has underscore
+--- config
+ location = /aggregate {
+ content_by_lua_block {
+ local core = require("apisix.core")
+ local t = require("lib.test_admin").test
+ local code, body = t('/apisix/batch-requests',
+ ngx.HTTP_POST,
+ [=[{
+ "headers": {
+ },
+ "pipeline":[
+ {
+ "path": "/c",
+ "headers": {
+ "x_real-ip": "127.0.0.2"
+ },
+ "method": "PUT"
+ }]
+ }]=],
+ [=[[
+ {
+ "status": 201,
+ "body":"C",
+ "headers": {
+ "Client-IP": "127.0.0.1",
+ "Client-IP-From-Hdr": "127.0.0.1"
+ }
+ }
+ ]]=])
+
+ ngx.status = code
+ ngx.say(body)
+ }
+ }
+
+ location = /c {
+ content_by_lua_block {
+ ngx.status = 201
+ ngx.header["Client-IP"] = ngx.var.remote_addr
+ ngx.header["Client-IP-From-Hdr"] =
ngx.req.get_headers()["x-real-ip"]
+ ngx.print("C")
+ }
+ }
+--- request
+GET /aggregate
+--- response_body
+passed