[英]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. 我将服务器130.153.32.231(Nginx)设置为www.mysite.com (Apache)的反向代理,它们都有单独的服务器,问题是如何获取访问130.153.32.231的用户真实IP地址并将其传递给www .mysite.com,而无需更改www.mysite.com中的任何内容,因为我看到的所有用户都显示130.153.32.231不是真正的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.. 已经尝试使用http_realip_module和proxy_set_header X-Forwarded-For,但是这些都无法完成,任何人都知道如何解决。
On the nginx side make sure you are passing through the remote address to the X-Forwarded-For header using something like: 在Nginx端,请确保使用以下方式将远程地址传递到X-Forwarded-For标头:
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: 然后在Apache端使用mod_remoteip( docs此处 )从X-Forwarded-For
标头获取IP地址:
RemoteIPInternalProxy 130.153.32.231
RemoteIPHeader X-Forwarded-For
You also need to tell Apache to trust the proxy (the RemoteIPInternalProxy does this). 您还需要告诉Apache信任代理(RemoteIPInternalProxy会这样做)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.