ryan4yin commented on issue #9691:
URL: https://github.com/apache/apisix/issues/9691#issuecomment-1815693828

   Here is the steps to reproduce my result:
   
   ```bash
   git clone https://github.com/apache/apisix-docker.git
   
   cat <<EOF >  0001-feat-test.patch
   From 9352a330815948a785fcfd33a674e0fc14e4119c Mon Sep 17 00:00:00 2001
   From: Ubuntu <[email protected]>
   Date: Fri, 17 Nov 2023 03:17:03 +0000
   Subject: [PATCH] feat: test
   
   ---
    example/apisix_conf/config.yaml |  5 +++++
    example/docker-compose.yml      | 22 ----------------------
    example/test/put-config.sh      |  9 +++++++++
    example/test/route.json         | 21 +++++++++++++++++++++
    example/test/upstream-web1.json | 20 ++++++++++++++++++++
    example/test/upstream-web2.json | 20 ++++++++++++++++++++
    6 files changed, 75 insertions(+), 22 deletions(-)
    create mode 100644 example/test/put-config.sh
    create mode 100644 example/test/route.json
    create mode 100644 example/test/upstream-web1.json
    create mode 100644 example/test/upstream-web2.json
   
   diff --git a/example/apisix_conf/config.yaml 
b/example/apisix_conf/config.yaml
   index 8012137..48df1d4 100644
   --- a/example/apisix_conf/config.yaml
   +++ b/example/apisix_conf/config.yaml
   @@ -49,3 +49,8 @@ plugin_attr:
        export_addr:
          ip: "0.0.0.0"
          port: 9091
   +  proxy-mirror:
   +    timeout:
   +      connect: 2000ms
   +      read: 2000ms
   +      send: 2000ms
   diff --git a/example/docker-compose.yml b/example/docker-compose.yml
   index 86e5495..703a7d7 100644
   --- a/example/docker-compose.yml
   +++ b/example/docker-compose.yml
   @@ -74,28 +74,6 @@ services:
        networks:
          apisix:
   
   -  prometheus:
   -    image: prom/prometheus:v2.25.0
   -    restart: always
   -    volumes:
   -      - ./prometheus_conf/prometheus.yml:/etc/prometheus/prometheus.yml
   -    ports:
   -      - "9090:9090"
   -    networks:
   -      apisix:
   -
   -  grafana:
   -    image: grafana/grafana:7.3.7
   -    restart: always
   -    ports:
   -      - "3000:3000"
   -    volumes:
   -      - "./grafana_conf/provisioning:/etc/grafana/provisioning"
   -      - "./grafana_conf/dashboards:/var/lib/grafana/dashboards"
   -      - "./grafana_conf/config/grafana.ini:/etc/grafana/grafana.ini"
   -    networks:
   -      apisix:
   -
    networks:
      apisix:
        driver: bridge
   diff --git a/example/test/put-config.sh b/example/test/put-config.sh
   new file mode 100644
   index 0000000..d2f0f31
   --- /dev/null
   +++ b/example/test/put-config.sh
   @@ -0,0 +1,9 @@
   +export API_KEY=edd1c9f034335f136f87ad84b625c8f1
   +export APISIX_HOST=127.0.0.1
   +
   +
   +curl -v -X PUT http://${APISIX_HOST}:9180/apisix/admin/upstreams  -H 
"X-API-KEY: ${API_KEY}" --data "@upstream-web1.json"
   +curl -v -X PUT http://${APISIX_HOST}:9180/apisix/admin/upstreams  -H 
"X-API-KEY: ${API_KEY}" --data "@upstream-web2.json"
   +
   +curl -v -X PUT http://${APISIX_HOST}:9180/apisix/admin/routes -H 
"X-API-KEY: ${API_KEY}" --data "@route.json"
   +
   diff --git a/example/test/route.json b/example/test/route.json
   new file mode 100644
   index 0000000..d0ebfc6
   --- /dev/null
   +++ b/example/test/route.json
   @@ -0,0 +1,21 @@
   +{
   +  "id": "test-route",
   +  "uris": [
   +    "/*"
   +  ],
   +  "hosts": [
   +    "xxx.com"
   +  ],
   +  "methods": [
   +    "PUT",
   +    "GET",
   +    "POST",
   +    "HEAD"
   +  ],
   +  "plugins": {
   +        "proxy-mirror": {
   +           "host": "http://web1";
   +        }
   +  },
   +  "upstream_id": "web2"
   +}
   diff --git a/example/test/upstream-web1.json 
b/example/test/upstream-web1.json
   new file mode 100644
   index 0000000..1377234
   --- /dev/null
   +++ b/example/test/upstream-web1.json
   @@ -0,0 +1,20 @@
   +{
   +    "id": "web1",
   +    "scheme": "http",
   +    "type":"roundrobin",
   +    "keepalive_pool": {
   +        "size": 10,
   +        "idle_timeout": 75,
   +        "requests": 1000
   +    },
   +    "nodes": {
   +       "web1:80": 1
   +    },
   +    "retries": 1,
   +    "retry_timeout": 0.1,
   +    "timeout": {
   +        "connect": 0.1,
   +        "send": 0.1,
   +        "read": 0.1
   +    }
   +}
   diff --git a/example/test/upstream-web2.json 
b/example/test/upstream-web2.json
   new file mode 100644
   index 0000000..9da1325
   --- /dev/null
   +++ b/example/test/upstream-web2.json
   @@ -0,0 +1,20 @@
   +{
   +    "id": "web2",
   +    "scheme": "http",
   +    "type":"roundrobin",
   +    "keepalive_pool": {
   +        "size": 10,
   +        "idle_timeout": 75,
   +        "requests": 1000
   +    },
   +    "nodes": {
   +       "web2:80": 1
   +    },
   +    "retries": 1,
   +    "retry_timeout": 0.1,
   +    "timeout": {
   +        "connect": 0.1,
   +        "send": 0.1,
   +        "read": 0.1
   +    }
   +}
   --
   EOF
   
   cd apisix-docker
   git checkout 2f226c7b606b06f4b5a35a782d482998f21cd640
   git apply ../0001-feat-test.patch
   
   docker-compose up -d
   ```
   
   Run tcpdump to capture the HTTP GET Request on both web1 and web2:
   
   ```
   docker-compose exec -it web1 sh -c "apk add tcpdump; tcpdump -A -i eth0 -s 0 
'tcp port 80 and tcp
   [((tcp[12:1] & 0xf0) >> 2):4] = 0x47455420'"
   ```
   
   ```
   docker-compose exec -it web2 sh -c "apk add tcpdump; tcpdump -A -i eth0 -s 0 
'tcp port 80 and tcp
   [((tcp[12:1] & 0xf0) >> 2):4] = 0x47455420'"
   ```
   
   Then test using curl, and compare the output of tcpdump:
   
   ```shell
   curl -H "Host: xxx.com" localhost:9080
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to