反向代理后面的Mediawiki使用代理地址填充用户IP地址

我有一个运行在fw机器上的apache,将不同的文件夹代理到不同的后端服务器,并且还将连接包装在SSL中。 …一个相当常见的设置。

可以预见的是,后端mediawiki实例认为所有访问都来自1个IP,即反向代理。 由于它是mediawikifunction的一个重要组成部分丢失,是否有可能传递正确的IP地址为mediawiki引用和用于用户pipe理和日志logging,即IP断言? HTTP标头是有道理的。

绝对。

如果您使用的是mod_proxy_http,Apache可能已经在X-Forwarded-For头中发送了真实的IP。

看起来MediaWiki通过在您的configuration中启用一个variables来支持这个开箱即用的function:

$wgUsePrivateIPs = true; $wgSquidServers = array( 'proxy fqdn', 'proxy ip address' ); 

更多信息: https : //www.mediawiki.org/wiki/Manual : $wgUsePrivateIPs

启用它将告诉MediaWiki从X-Forwarded-For头中读取客户端IP。

你可以尝试下面的模块为Apache

 # yum info mod_extract_forwarded Name : mod_extract_forwarded Arch : x86_64 Version : 2.0.2 Release : 8.el6 Size : 15 k Repo : epel Summary : Extract real source IP for forwarded HTTP requests URL : http://www.openinfo.co.uk/apache/ License : ASL 1.1 Description : mod_extract_forwarded hooks itself into Apache's header parsing phase and looks : for the X-Forwarded-For header which some (most?) proxies add to the proxied : HTTP requests. It extracts the IP from the X-Forwarded-For and modifies the : connection data so to the rest of Apache the request looks like it came from : that IP rather than the proxy IP.