Apache 獲取真實ip的配置

最近由於用了web應用防火牆產品(阿里雲的),因此獲取不到用戶的真實ip。web

通過多方蒐集嘗試,方案以下:apache

apache2.4提供了自帶的remoteip模塊能夠實現獲取真實ip。vim

個人環境是:ubunt16.04 Apache2.4.18阿里雲

cd /etc/apache2.mods-availableip

新建配置文件 vim remoteip.confrem

輸入:產品

RemoteIPHeader X-Forwarded-For配置

RemoteIPProxiesHeader X-Forwarded-By防火牆

保存im

啓用:

a2enmod remoteip

重啓apache便可生效。

相關文章
相關標籤/搜索