Quantcast
Channel: User mikyll98 - Stack Overflow
Viewing all articles
Browse latest Browse all 104

Answer by mikyll98 for Configure Multiple Global Rules in APISix Standalone Mode

$
0
0

From API7 Docs | Plugin Global Rules you can read:

If the same plugin is configured in both objects, both instances of the plugin will be executed sequentially, rather than overwriting each other.

I've tested this on Docker, with APISIX deployed in Standalone mode:

  • File compose.yaml:
services:  apisix-standalone:    container_name: apisix-standalone    image: apache/apisix:latest    restart: always    environment:      - APISIX_STAND_ALONE=true    volumes:      - ./apisix_conf_standalone/config.yaml:/usr/local/apisix/conf/config.yaml      - ./apisix_conf_standalone/apisix.yaml:/usr/local/apisix/conf/apisix.yaml    ports:      - "9080:9080/tcp"      - "9443:9443/tcp"
  • File conf/config.yaml:
deployment:  role: data_plane  role_data_plane:    config_provider: yaml
  • File conf/apisix.yaml:
global_rules:  - id: 1    plugins:      response-rewrite:        headers:          set:            x-my-header-1: test  - id: 2    plugins:      response-rewrite:        headers:          set:            x-my-header-2: testroutes:  - id: base    uri: /status/200    upstream:      nodes:"httpbin.org": 1      type: roundrobin#END

Test request:

curl localhost:9080/status/200 -iHTTP/1.1 200 OKContent-Type: text/html; charset=utf-8Content-Length: 0Connection: keep-aliveDate: Tue, 11 Feb 2025 11:00:40 GMTAccess-Control-Allow-Origin: *Access-Control-Allow-Credentials: trueServer: APISIX/3.11.0x-my-header-1: testx-my-header-2: test

As we can notice, the response shows both the headers, confirming that the plugins are executed sequentially, rather than overwriting each other.


However, trying your example, it indeed seems to parse only the second rule, and I think it has something to do with vars but I'm not quite sure... To get a clue of what could be the issue, you can have a look at response-rewrite code


Viewing all articles
Browse latest Browse all 104

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>