역방향 프록시 및 클라이언트 IP 뒤의 mod_security

역방향 프록시 및 클라이언트 IP 뒤의 mod_security
client -> haproxy -> mod_security boxes -> backends

문제: mod_security 상자는 'RPAFproxy_ips'에서 haproxy의 IP와 함께 mod_rpaf를 사용합니다. Apache 로깅에는 클라이언트의 실제 IP가 표시되지만 mod_security는 아래와 같이 여전히 haproxys IP를 보고합니다.

mod_sec 상자의 Apache 로그에서 클라이언트 IP가 발견되었습니다.

x.93.129.90 - - [14/Oct/2015:08:35:56 +0200] "GET /MYTEST HTTP/1.1" 301 524 "-" "curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5"

Mod_security는 프록시 IP를 보고합니다(클라이언트 x.21.107.165).

 ==> /var/log/apache2/site.se_error.log <==
[Wed Oct 14 08:36:12.584500 2015] [:error] [pid 10264:tid 139895758558976]  [client x.21.107.165] ModSecurity: Access denied with code 403 (phase 2). 
Pattern match "\\\\balert\\\\b[^a-zA-Z0-9_]{0,}?\\\\(" at ARGS_NAMES:
<script>alert(1)</script>. [file "/usr/share/cwaf/rules/07_XSS_XSS.conf"] <etc>..

웹상의 사람들은 mod_sec로 rpaf를 실행하는 것 같습니다. 제가 뭔가 잘못하고 있는 걸까요?

또 다른 좋은 접근 방식을 아는 사람이 있나요? 기본적으로 헤더의 값이 있는 경우 이를 사용하고 그렇지 않으면 원격_주소로 대체하는 일부 mod_sec 규칙을 보았지만 해당 규칙이 작동하지 않았습니다.

답변1

mod_rpaf는 apache < 2.4에서만 작동하고, mod_remoteip는 2.4에서 작동하며, mod_security는 이제 로드 밸런서/프록시가 아닌 클라이언트 IP를 보고합니다.

우분투 14.04에서

a2enmod remoteip
echo "RemoteIPHeader X-Client-Ip" > /etc/apache2/mods-enabled/remoteip.conf
service apache2 restart

관련 정보