在 apache 中将 REMOTE_ADDR 设置为 X-Forwarded-For [英] Set REMOTE_ADDR to X-Forwarded-For in apache
问题描述
在 Apache 位于反向代理(例如 Squid)后面的情况下,cgi 环境变量 REMOTE_ADDR
获取代理的地址而不是客户端.
In a situation where Apache is sitting behind a reverse proxy (such as Squid), the cgi environment variable REMOTE_ADDR
gets the address of the proxy rather than the client.
但是,代理会设置一个名为 X-Forwarded-For
的标头来包含客户端的原始 IP 地址,以便 Apache 可以看到它.
However, the proxy will set a header called X-Forwarded-For
to contain the original IP address of the client so that Apache can see it.
问题是,我们如何让 Apache 将 REMOTE_ADDR
替换为 X-Forwarded-For
标头中的值,以便所有 Web 应用程序都能透明地看到正确的地址?
The question is, how do we get Apache to replace REMOTE_ADDR
with the value in the X-Forwarded-For
header so that all of the web applications will transparently see the correct address?
推荐答案
您可以使用 mod_rpaf.http://stderr.net/apache/rpaf/
You can use mod_rpaf for that. http://stderr.net/apache/rpaf/
这篇关于在 apache 中将 REMOTE_ADDR 设置为 X-Forwarded-For的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!