cloudflare 원래 방문자의 IP 표시 (Apache로 mod_remoteip 설치)

안녕하세요? WEBPD.NET 서버운영팀입니다.

cloudflare 원래 방문자의 IP 표시 (Apache로 mod_remoteip 설치)를 안내해드립니다.

 

자세한 내용은 아래 주소를 클릭하시면 정보를 확인하실 수 있습니다.

https://support.cloudflare.com/hc/ko/articles/360029696071

 

개요

Cloudflare는 이제 mod_cloudflare를 업데이트하거나 지원하지 않습니다.하지만 Ubuntu Server 18.04Debian 9 Stretch 등의 운영체제로 Apache 웹 서버를 사용 중인 경우, mod_remoteip를 사용해 원래 방문자의 IP 주소를 기록할 수 있습니다.

mod_cloudflare 패키지 구축에 관심이 있는 고객은 GitHub에서 코드베이스를 다운로드할 수 있습니다.

mod_remoteip 설치

이 모듈은 외부 개발자가 개발한 것이기 때문에 Cloudflare는 이 모듈과 관련된 문제에 대해 기술 지원을 제공할 수 없습니다.

다음의 단계에 따라 mod_remoteip 를 Apache 웹 서버에 설치합니다.

1. 다음의 명령어를 실행해 mod_remoteip를 활성화합니다.

sudo a2enmod remoteip

2. RemoteIPHeader CF-Connecting-IP가 포함되도록 사이트 설정을 업데이트합니다(예: RemoteIPHeader CF-Connecting-IP)

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName remoteip.andy.support
RemoteIPHeader CF-Connecting-IP
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

3. apache.conf에서 결합된 LogFormat 항목을 업데이트해 /etc/apache2/apache2.conf.의 %h  %a로 대체합니다. 예를 들면, 현재 LogFormat이 다음과 같이 표시될 경우,

LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined

LogFormat을 다음과 같이 업데이트해야 합니다.

LogFormat "%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined

4. 아래의 코드와 Cloudflare IP를 입력해 /etc/apache2/conf-available/remoteip.conf를 생성하여 신뢰할 수 있는 프록시 주소를 정의합니다.

RemoteIPHeader CF-Connecting-IP
RemoteIPTrustedProxy 173.245.48.0/20
RemoteIPTrustedProxy 103.21.244.0/22
RemoteIPTrustedProxy 103.22.200.0/22
RemoteIPTrustedProxy 103.31.4.0/22
RemoteIPTrustedProxy 141.101.64.0/18
RemoteIPTrustedProxy 108.162.192.0/18
RemoteIPTrustedProxy 190.93.240.0/20
RemoteIPTrustedProxy 188.114.96.0/20
RemoteIPTrustedProxy 197.234.240.0/22
RemoteIPTrustedProxy 198.41.128.0/17
RemoteIPTrustedProxy 162.158.0.0/15
RemoteIPTrustedProxy 104.16.0.0/12
RemoteIPTrustedProxy 172.64.0.0/13
RemoteIPTrustedProxy 131.0.72.0/22
RemoteIPTrustedProxy 2400:cb00::/32
RemoteIPTrustedProxy 2606:4700::/32
RemoteIPTrustedProxy 2803:f800::/32
RemoteIPTrustedProxy 2405:b500::/32
RemoteIPTrustedProxy 2405:8100::/32
RemoteIPTrustedProxy 2a06:98c0::/29
RemoteIPTrustedProxy 2c0f:f248::/32

3. Apache 설정을 테스트합니다.

sudo apache2ctl configtest
Syntax OK

6. Apache를 재시작합니다.

sudo systemctl restart apache2
mod_remoteip에 관한 자세한 정보는 Apache 문서에서 확인할 수 있습니다.
이 답변이 도움이 되었습니까? 108 명의 사용자가 추천했습니다. (214 추천)