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

   ### Description
   
   I have deployed an Apisix instance in ingress mode in a K8S cluster by Helm. 
For monitoring, I want keep logs where i can have the source IP of the request. 
When I look Apisix logs, I don't understand which Ip source is used. Currently, 
I have (IP are not sensible - testing only):
   
   ```
   NAME                                             READY   STATUS    RESTARTS  
 AGE     IP            NODE                 NOMINATED NODE   READINESS GATES
   pod/apisix-5bc44bdcf-b9c8d                       1/1     Running   0         
 7m20s   10.0.1.37     XXX   <none>           <none>
   pod/apisix-etcd-0                                1/1     Running   0         
 7m20s   10.0.10.249   XXX  <none>           <none>
   pod/apisix-etcd-1                                1/1     Running   0         
 7m20s   10.0.1.202    XXX   <none>           <none>
   pod/apisix-etcd-2                                1/1     Running   0         
 7m20s   10.0.9.197    XXX  <none>           <none>
   pod/apisix-ingress-controller-64f87d6476-46s8p   1/1     Running   0         
 7m20s   10.0.10.138   XXX   <none>           <none>
   
   NAME                                               TYPE        CLUSTER-IP    
   EXTERNAL-IP   PORT(S)                      AGE     SELECTOR
   service/apisix-admin                               ClusterIP   
10.105.167.148   <none>        9180/TCP                     7m20s   
app.kubernetes.io/instance=apisix,app.kubernetes.io/name=apisix
   service/apisix-etcd                                ClusterIP   10.106.95.79  
   <none>        2379/TCP,2380/TCP            7m20s   
app.kubernetes.io/instance=apisix,app.kubernetes.io/name=etcd
   service/apisix-etcd-headless                       ClusterIP   None          
   <none>        2379/TCP,2380/TCP            7m20s   
app.kubernetes.io/instance=apisix,app.kubernetes.io/name=etcd
   service/apisix-gateway                             NodePort    10.101.239.32 
   <none>        80:32080/TCP,443:32443/TCP   7m20s   
app.kubernetes.io/instance=apisix,app.kubernetes.io/name=apisix
   service/apisix-ingress-controller                  ClusterIP   10.97.78.168  
   <none>        80/TCP                       7m20s   
app.kubernetes.io/instance=apisix,app.kubernetes.io/name=ingress-controller
   service/apisix-ingress-controller-apisix-gateway   NodePort    10.99.249.217 
   <none>        80:31814/TCP,443:30993/TCP   7m20s   
app.kubernetes.io/instance=apisix,app.kubernetes.io/name=ingress-controller
   service/apisix-prometheus-metrics                  ClusterIP   10.99.126.116 
   <none>        9091/TCP                     7m20s   
app.kubernetes.io/instance=apisix,app.kubernetes.io/name=apisix
   ```
   If I look `kubectl logs service/apisix-gateway -c apisix -n ingress-apisix`:
   ```
   10.0.10.138 - - [30/Oct/2023:12:12:36 +0000] 
apisix-admin.ingress-apisix.svc.cluster.local:9180 "PUT 
/apisix/admin/routes/48fa1ac1 HTTP/1.1" 201 367 0.017 "-" "Go-http-client/1.1" 
- - - "http://apisix-admin.ingress-apisix.svc.cluster.local:9180";
   10.0.10.220 - - [30/Oct/2023:12:12:41 +0000] httpbin:32080 "GET / HTTP/1.1" 
200 9593 0.005 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, 
like Gecko) Chrome/117.0.0.0 Safari/537.36" 10.0.6.191:80 200 0.006 
"http://httpbin:32080";
   10.0.10.220 - - [30/Oct/2023:12:12:41 +0000] httpbin:32080 "GET /spec.json 
HTTP/1.1" 200 41019 0.009 "http://httpbin:32080/"; "Mozilla/5.0 (X11; Linux 
x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36" 
10.0.6.191:80 200 0.010 "http://httpbin:32080";
   ```
   Pods:
   ```
   pod/httpbin                      1/1     Running   0          170m    
10.0.6.191   XXX   <none>           <none>
   service/httpbin      ClusterIP   10.102.240.255   <none>        80/TCP    
176m   run=httpbin
   ```
   
   `apisix-admin.ingress-apisix.svc.cluster.local:9180` seems to be a request 
from `apisix-ingress-controller-64f87d6476-46s8p`. Ok.
   
   But when I do `curl http://httpbin:32080/get`:
   ```
   {
     "args": {}, 
     "headers": {
       "Accept": "*/*", 
       "Host": "httpbin:32080", 
       "User-Agent": "curl/7.81.0", 
       "X-Forwarded-Host": "httpbin"
     }, 
     "origin": "10.0.10.220", 
     "url": "http://httpbin/get";
   }
   ```
   
   What is `10.0.10.220` ? It should be the Ip from my machine and it is not. 
What ip is logged by Apisix and how can we have the real source IP ?
   
   ### Environment
   
   - APISIX version (run `apisix version`): apisix-1.7.1 (helm) - 3.6.0
   - Operating system (run `uname -a`):
   - OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
   - 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