siaron commented on issue #5223:
URL: https://github.com/apache/apisix/issues/5223#issuecomment-942896502


   @tokers 在自定义的负载均衡插件中如何获取客户端ip, 我打印ctx为
   ```
   {
     "conf_id": "376794584073634862",
     "balancer_try_count": 1,
     "var": {
       "_request": "cdata<void *>: 0x7fb862020850",
       "_cache": {
         "upstream_scheme": "http",
         "host": "127.0.0.1",
         "uri": "/uaa/test/hello",
         "remote_addr": "127.0.0.1",
         "request_method": "GET"
       }
     },
     "route_id": "376794584073634862",
     "route_name": "uaa",
     "plugins": {},
     "matched_upstream": {
       "type": "original_destination",
       "keepalive_pool": "table: 0x0a176800",
       "create_time": 1634116608,
       "discovery_type": "nacos",
       "name": "uaa",
       "id": "376794475088839726",
       "timeout": "table: 0x13c7bf98",
       "update_time": 1634178548,
       "desc": "uaa服务",
       "hash_on": "vars",
       "pass_host": "pass",
       "scheme": "http",
       "service_name": "uaa-service",
       "parent": "table: 0x13c761a8",
       "key": 
"{\"redis_host\":\"127.0.0.1\",\"redis_port\":6379,\"redis_password\":\"redis\",\"redis_database\":0,\"redis_timeout\":1001,\"http_header\":\"server_host\",\"client_ip_header\":\"remote_addr\"}",
       "nodes": "table: 0x1887a580"
     },
     "curr_req_matched": {
       "_path": "/uaa/*",
       ":ext": "test/hello",
       "_method": "GET"
     },
     "upstream_scheme": "http",
     "upstream_healthcheck_parent": {
       "modifiedIndex": 1827,
       "key": "/apisix/upstreams/376794475088839726",
       "createdIndex": 1378,
       "clean_handlers": {},
       "value": {
         "create_time": 1634116608,
         "hash_on": "vars",
         "scheme": "http",
         "key": 
"{\"redis_host\":\"127.0.0.1\",\"redis_port\":6379,\"redis_password\":\"redis\",\"redis_database\":0,\"redis_timeout\":1001,\"http_header\":\"server_host\",\"client_ip_header\":\"remote_addr\"}",
         "discovery_type": "nacos",
         "type": "original_destination",
         "keepalive_pool": {
           "requests": 1000,
           "size": 320,
           "idle_timeout": 60
         },
         "name": "uaa",
         "nodes": "table: 0x1863bdc0",
         "desc": "uaa服务",
         "service_name": "uaa-service",
         "id": "376794475088839726",
         "nodes_ref": [
           {
             "host": "192.168.27.173",
             "port": 30101,
             "weight": 1,
             "priority": 0
           },
           {
             "host": "192.168.27.173",
             "port": 20101,
             "weight": 1,
             "priority": 0
           }
         ],
         "timeout": {
           "send": 6,
           "connect": 6,
           "read": 6
         },
         "update_time": 1634178548,
         "parent": "table: 0x13c761a8",
         "pass_host": "pass",
         "original_nodes": [
           {
             "port": 30101,
             "weight": 1,
             "host": "192.168.27.173"
           },
           {
             "port": 20101,
             "weight": 1,
             "host": "192.168.27.173"
           }
         ]
       },
       "has_domain": false
     },
     "upstream_version": 1380,
     "upstream_key": "original_destination#upstream_table: 0x18630ae0",
     "upstream_conf": "table: 0x18630ae0",
     "conf_type": "route",
     "matched_route": {
       "modifiedIndex": 1380,
       "update_count": 0,
       "key": "/apisix/routes/376794584073634862",
       "createdIndex": 1380,
       "value": {
         "name": "uaa",
         "methods": [
           "GET",
           "POST",
           "PUT",
           "DELETE",
           "PATCH",
           "HEAD",
           "OPTIONS",
           "CONNECT",
           "TRACE"
         ],
         "update_time": 1634116673,
         "upstream_id": "376794475088839726",
         "priority": 0,
         "uri": "/uaa/*",
         "status": 1,
         "id": "376794584073634862",
         "create_time": 1634116673
       },
       "clean_handlers": {},
       "has_domain": false,
       "orig_modifiedIndex": 1380
     },
     "conf_version": 1380
   }
   ```


-- 
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