如何使drupal看到nginx反向代理->清漆-> Apache堆栈后面的客户端IP?

问题描述 投票:0回答:1

[我正在使用nginx作为处理端口80的反向代理-> 443重定向,然后到清漆缓存(端口8181)上,该缓存与服务于drupal(7.69)站点的Apache2.4后端(端口8182)进行通信。] >

我已将nginx配置为将客户端IP转发为:

proxy_pass            http://127.0.0.1:8181;
proxy_read_timeout    90;
proxy_connect_timeout 90;
proxy_redirect        off;
proxy_set_header      X-Real-IP $remote_addr;
proxy_set_header      X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header      X-Forwarded-Proto https;
proxy_set_header      X-Forwarded-Port 443;
proxy_set_header      X-Forwarded-Host $remote_addr;
proxy_set_header      Host $host;

在清漆vcl_recv中,我要添加:

if (req.restarts == 0) {
  if (req.http.X-Forwarded-For) {
    set req.http.X-Forwarded-For =
    req.http.X-Forwarded-For + ", " + client.ip;
  } else {
    set req.http.X-Forwarded-For = client.ip;
  }
}

在apache中,我已经安装了remoteip模块并设置了以下配置:

RemoteIPHeader X-Forwarded-For
RemoteIPTrustedProxy 127.0.0.1

在drupal的settings.php中,我有

$conf['reverse_proxy'] = True;
$conf['reverse_proxy_header'] = 'X-Forwarded-For';
$conf['reverse_proxy_addresses'] = array('127.0.0.1');

...但是尽管如此,drupal似乎只看到并登录了本地主机(127.0.0.1)ip,而不是真正的客户端IP。因此,表单的登录记录不是来自真实用户,而是服务器本身。

我想知道我的清漆配置是否已关闭,因为我还从nginx代理并绕过清漆,直接进入一个绕过drupal(它是SMF)但在相同的apache配置上运行的论坛;论坛正在记录从nginx发送的客户端IP(使用相同的标头更改和apache remoteip配置)就可以了。

非常感谢您的指导/建议。

我使用nginx作为处理端口80的反向代理-> 443重定向,然后到清漆缓存(端口8181)上,该缓存与服务于drupal(7.69)站点的Apache2.4后端(端口8182)进行通信。我有...

drupal-7 varnish nginx-reverse-proxy apache2.4
1个回答
0
投票

清漆

© www.soinside.com 2019 - 2024. All rights reserved.