클라우드 플레어를 서버에 적용했을 경우 방문자가 클라우드플레어 서버를 경유하게 되므로 방문자의 실제 아이피가 아닌 클라우드플레어 아이피대역으로 기록됩니다.
이럴 경우 악성유저가 활동할 때 이를 추적하여 세컨 계정을 찾아낸다거나 아이피를 차단하는데 어려움이 있습니다.
(방문자 아이피 추적이 불가함)
그에대한 대응방법입니다.
Overview
Cloudflare는 더 이상 mod_cloudflare를 업데이트하고 지원하지 않습니다 . 그러나 Ubuntu Server 18.04 및 Debian 9 Stretch 와 같은 운영 체제에서 Apache 웹 서버를 사용하는 경우 mod_remoteip 를 사용 하여 방문자의 원래 IP 주소를 기록 할 수 있습니다 .
▼
Installing mod_remoteipApache 웹 서버에 mod_remoteip 설치하기
1. 다음 명령을 실행하여 mod_remoteip 를 활성화합니다 .
sudo a2enmod remoteip
2. RemoteIPHeader CF-Connecting-IP 를 포함하도록 사이트 구성을 업데이트합니다.
예)
예)
/etc/apache2/sites-available/000-default.conf
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
3.
예)아래와 같이 설정되어 있는 파일을,
아래와 같이 바꿉니다.
/etc/apache2/apache2.conf
파일의 LogFormat 행에서 %h를 %a로 바꿉니다. 예)아래와 같이 설정되어 있는 파일을,
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
아래와 같이 바꿉니다.
LogFormat "%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
4.
/etc/apache2/conf-available/remoteip.conf
파일에 아래 코드와 함께 (Cloudflare IPs)대역을 입력합니다. 아래 아이피 대역은 작성일 기준이며 최신 아이피대역은 첨부한 링크를 참고하세요.
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
5. 구성을 활성화합니다.
sudo a2enconf remoteip
Enabling conf remoteip.
To activate the new configuration, you need to run:
service apache2 reload
6. 구성을 테스트합니다.
sudo apache2ctl configtest
Syntax OK
7. Apache를 다시 시작합니다.
sudo systemctl restart apache2
끝.
마침.
'취미│Back-End > SERVER' 카테고리의 다른 글
가상머신(버츄얼박스, Vmware)에 우분투 리눅스 데스크탑 버전 설치하기 (0) | 2021.01.17 |
---|---|
vmware에 우분투 서버버전(Ubuntu Server 20.04.1 LTS) 설치 (0) | 2021.01.12 |
Debian / Ubuntu에 Dante 설치 및 다중아이피 Socks5 프록시 서버 구성하기 (1) | 2021.01.11 |