I'm analyzing a stack of a public route that rests on an Elastic Load Balancer which opens a port exposed by PM2 that starts a node app using the koa module. At the moment, the IP is logged and that depends solely on the X-Forwarded-For
header. If this header is manually created using curl
, then the application will write that as the IP address.
Is there an easy way to prevent spoofing of this header or to setup AWS's ELB so it ignores manually inserted headers or is there a better way than the spoofable header to get the real IP address of the visitor?
ctx.request.ip
. This is filled by AWS's ELB which I think may be setting the lastX-Forwarded-IP
(in this case, it's spoofed) at the end of the array. – Laundress