I have configured nginx as a reverse proxy. However, ghost always gets the same ip 127.0.0.1 from request forwarded to it by nginx.
How can I make ghost to get the real IP from nginx?
My configuration of nginx includes the following statements
proxy_set_header Host $http_host;
proxy_set_header X-real-ip $remote_addr;
You should try retrieve the IP address first from headers:
It is not recommended to override
req.connection.remoteAddress
directly since it will confuse other programmers you collaborated with. But it is technically possible. TheremoteAddress
is a getter so you can't assign value to it directly, you need to define your own getter: