简体   繁体   中英

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..

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM