j7ourenz opened a new issue, #9794:
URL: https://github.com/apache/apisix/issues/9794

   ### Description
   
   ### Setup:
   apisix.yaml
   ```
   routes:
     - id: backend
       uri: /*
       upstream:
         nodes:
           "backend.example.internal:8888": 1
         type: chash
         # key: remote_addr # default
       plugin_config_id: 1
   
        # alternate config:
        # type: chash
        # hash_on: header
        # key: x-forwarded-for
      
   plugin_configs:
     - id: 1
       plugins:
         real-ip:
           source: http_x_forwarded_for
           trusted_addesses:
             - ${{VPC_CIDR}}
   ```
   
   ```
   nslookup backend.example.internal
   Address: 10.0.0.10
   Address: 10.0.0.20
   Address: 10.0.0.30
   ```
   
   ### Expected Behaviour:
   Client will end up on the same backend server (sticky session).
   ```
   Sample logs:
   $remote_addr - \"$request\ - \"$http_x_forwarded_for\" - \"$upstream_addr\"
   <client's ip> - "GET" - <client's ip> - "10.0.0.10:8888"
   <client's ip> - "GET" - <client's ip> - "10.0.0.10:8888"
   <client's ip> - "GET" - <client's ip> - "10.0.0.10:8888"
   <client's ip> - "GET" - <client's ip> - "10.0.0.10:8888"
   <client's ip> - "GET" - <client's ip> - "10.0.0.10:8888"
   ```
   
   ### Actual Behaviour:
   Client end up in random backend.
   ```
   sample logs:
   $remote_addr - \"$request\ - \"$http_x_forwarded_for\" - \"$upstream_addr\"
   <client's ip> - "GET" - <client's ip> - "10.0.0.10:8888"
   <client's ip> - "GET" - <client's ip> - "10.0.0.10:8888"
   <client's ip> - "GET" - <client's ip> - "10.0.0.20:8888"
   <client's ip> - "GET" - <client's ip> - "10.0.0.30:8888"
   <client's ip> - "GET" - <client's ip> - "10.0.0.20:8888"
   <client's ip> - "GET" - <client's ip> - "10.0.0.10:8888"
   ```
   
   ### Additional Information:
   This is the nginx config I'm trying to achieve/replicate which is working 
minus the resolver in upstream.
   ```
   upstream backend {
           ip_hash;
           server backend.example.internal:8888;
           keepalive 16;
   }
   
   server {
           set_real_ip_from ${{VPC_CIDR}};
           real_ip_header X-Forwarded-For;
   
           location / {
                   proxy_pass                           http://backend;
                   proxy_set_header                Host $host;
                   proxy_set_header                X-Forwarded-For $remote_addr;
                   proxy_set_header                X-Forwarded-Proto 
$http_x_forwarded_proto;
                   proxy_next_upstream          error timeout http_502 http_503 
http_504;
          }
   }
   ```
   
   For each request, resolver.lua returns one (random) IP of the domain.
   ```
   resolver.lua:88: parse_domain(): dns resolver domain: 
backend.example.internal to 10.0.0.10
   resolver.lua:88: parse_domain(): dns resolver domain: 
backend.example.internal to 10.0.0.10
   resolver.lua:88: parse_domain(): dns resolver domain: 
backend.example.internal to 10.0.0.20
   resolver.lua:88: parse_domain(): dns resolver domain: 
backend.example.internal to 10.0.0.30
   resolver.lua:88: parse_domain(): dns resolver domain: 
backend.example.internal to 10.0.0.20
   resolver.lua:88: parse_domain(): dns resolver domain: 
backend.example.internal to 10.0.0.10
   ```
   
   Am I missing something here or what I'm trying to achieve is not possible?
   Thanks!
   
   
   ### Environment
   
   - APISIX version (run `apisix version`): 3.2.1
   - Operating system (run `uname -a`): Amazon Linux 2
   - OpenResty / Nginx version (run `openresty -V` or `nginx -V`):  
openresty/1.21.4.1
   - etcd version, if relevant (run `curl 
http://127.0.0.1:9090/v1/server_info`):
   - APISIX Dashboard version, if relevant:
   - Plugin runner version, for issues related to plugin runners:
   - LuaRocks version, for installation issues (run `luarocks --version`):
   


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