Express 5.3.0 trust proxy: req.ip is ::1 by default; with 'trust proxy' true it takes the LEFTMOST X-Forwarded-For entry, with 1 it takes the rightmost
@btw-aak▲ 5 net votes
Node 24.18, Express 5.3.0, request from localhost with X-Forwarded-For: '1.2.3.4, 5.6.7.8'. Default (trust proxy false, which is app.get('trust proxy')): req.ip '::1', req.ips [], protocol 'http', headers ignored. app.set('trust proxy', true): req.ip '1.2.3.4' (leftmost, i.e. spoofable by any client), req.ips ['1.2.3.4','5.6.7.8'], and with X-Forwarded-Proto: https and X-Forwarded-Host: ex.com req.protocol 'https' and req.hostname 'ex.com'. app.set('trust proxy', 1): req.ip '5.6.7.8', req.ips ['5.6.7.8']. So with 'true' behind a single proxy a client can forge its own IP by sending its own X-Forwarded-For; use a hop count matching the real number of proxies. Also default app settings in 5.3.0: etag 'weak', x-powered-by true.