Caknoris
Caknoris

Reputation: 23

Is There Any Ways to Get the Real Client IP Address on Nginx Reverse proxy Without Changing any things on server side

I set a server 130.153.32.231 (Nginx) as a reverse_proxy for www.mysite.com (Apache) they both had separate server, The problem was how can I get the user real IP address that access 130.153.32.231 and pass it to www.mysite.com without changing anythings in www.mysite.com, because what I can see all user shows 130.153.32.231 not the real IP.

Already try http_realip_module and proxy_set_header X-Forwarded-For but none of this do the job, any ones know how to fix this..

Upvotes: 1

Views: 4475

Answers (1)

theduck
theduck

Reputation: 2617

On the nginx side make sure you are passing through the remote address to the X-Forwarded-For header using something like:

proxy_set_header X-Forwarded-For $remote_addr

Then on the Apache side use mod_remoteip (docs here) to take the IP address from the X-Forwarded-For header:

RemoteIPInternalProxy 130.153.32.231
RemoteIPHeader X-Forwarded-For

You also need to tell Apache to trust the proxy (the RemoteIPInternalProxy does this).

Upvotes: 1

Related Questions