4,356,279 th visitor since 2017.2.1 ( Today : 763 )
Computer ???
No. 486
Name. swindler
Subject. HAProxy IP 전달 관련 (mod_rpaf 설치)
Main Cate. Linux
Sub Cate.
Date. 2017-12-20 12:19
Hit. 3745 (125.131.199.20)
File.
일반적으로는 웹서버에서 access log를 확인하면
client ip가 아니라, haproxy 서버 ip가 출력된다.

일단 defaults 섹션에
option forwarfor
를 설정하면, 클라이언트 정보를 전달하게 된다.


첫번째 방법으로는 header의 X-Forwarded-For 를 출력하도록 로그 포맷을 변경한다.
apache LogFormat에서 %h -> %{X-Forwarded-For}i 로 수정.


두번재로는 mod_rpaf 모듈을 설치하여 HTTP 헤더 자체를 변경하는 방법이다.


- mod_rpaf : http://www.stderr.net/apache/rpaf

$ wget http://www.stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gz
$ tar zxvf mod_rpaf-0.6.tar.gz
$ cd mod_rpaf-0.6
$ apxs -i -c -n mod_rpaf.so mod_rpaf.c
$ vi /etc/httpd/conf/httpd.conf

LoadModule rpaf_module modules/mod_rpaf.so

<IfModule rpaf_module>

RPAF_Enable On
RPAF_SetHostNAme On
RPAF_ProxyIPs {haproxy서버 아이피}
RPAF_Header X-Forwarded-For

## 여러 아이피를 지정할 경우 스페이스 후에 연속하여 기술
## RPAF_ProxyIPs 127.0.0.1 xxx.xxx.xxx.xxx

</IfModule>

[바로가기 링크] : http://coolx.net/cboard/computer/486



swindler mod_rpaf 를 설치하더라도 Apache Log에서는 Proxy 주소가 찍히므로 X-Forwarded-For 를 주어야 실제 client ip 가 출력된다. 2017-12-27
Name
Password
Comment
Copyright © 1999-2017, swindler. All rights reserved. 367,611 visitor ( 1999.1.8-2004.5.26 ), 2,405,771 ( -2017.01.31)

  2HLAB   2HLAB_Blog   RedToolBox   Omil   Omil_Blog