728x90
반응형
#아파치 #RewriteRule 다중 조건 설정

https://pixabay.com/users/geralt-9301/
SMTP가 작동하지 않는다는 알람이 떠서 확인해 보니 #Amazonbot이 과다 접속을 해서 DB 부하를 일으키고 있는 것으로 확인됐다.
| 52.70.240.171 - - [15/Mar/2024:11:25:29 +0900] "GET /pacai3/shopping/order.php?good_id=901 HTTP/1.1" 200 36289 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/600.2.5 (KHTML, like Gecko) Version/8.0.2 Safari/600.2.5 (Amazonbot/0.1; +https://developer.amazon.com/support/amazonbot)" 52.70.240.171 - - [15/Mar/2024:11:25:37 +0900] "GET /pacai3/shopping/order.php?good_id=910 HTTP/1.1" 200 36289 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/600.2.5 (KHTML, like Gecko) Version/8.0.2 Safari/600.2.5 (Amazonbot/0.1; +https://developer.amazon.com/support/amazonbot)" 52.70.240.171 - - [15/Mar/2024:11:25:33 +0900] "GET /pacai3/shopping/order.php?good_id=900 HTTP/1.1" 200 36289 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/600.2.5 (KHTML, like Gecko) Version/8.0.2 Safari/600.2.5 (Amazonbot/0.1; +https://developer.amazon.com/support/amazonbot)" |
그래서 일단 아이피를 차단하고 #.htaccess를 통해 차단 설정을 하였다.
URL과 Bot 차단 2가지 설정으로 Rewrite를 설정했는데 2번째인 Bot 차단이 작동하지 않았다.
확인해 보니 다중 조건을 설정할 때는 "OR"를 넣어줘야 한다.
최종 설정은
| RewriteEngine On RewriteCond %{QUERY_STRING} (test|user|password|information_schema) [NC,OR] RewriteCond %{HTTP_USER_AGENT} (gumgum-bot|postmanruntime|ag_dm_spider|scrapy|chimeboti|Bytespider|Amazonbot|MJ12bot) [NC] RewriteRule .* - [F,L] |
이다.
참고사이트: https://serverfault.com/questions/293160/apache-rewrite-multiple-conditions
Apache rewrite multiple conditions
I have a website that's migrated from an old domain name (e.g. olddomain.com) to a new domain name (e.g. newdomain.com). For SEO reasons, I need to rewrite all website traffic to the primary new d...
serverfault.com
728x90
반응형
'IT인터넷 > 리눅스' 카테고리의 다른 글
| iptables 규칙에 주석 달기 (0) | 2024.04.16 |
|---|---|
| 터미널로 리눅스 네트워크 관리하기 (0) | 2024.04.15 |
| PROXMOX Cluster 제거 방법 (0) | 2024.04.09 |
| 데비안 리눅스 아이피 추가 (debian ip alias) / feat. PMG (0) | 2024.04.09 |
| Postfix 5분 지연 발송 (0) | 2024.03.27 |