★리눅스 설정 불필요한 서비스 비활성화 예: FTP, Telnet 등 sudo systemctl disable <서비스 이름> sudo systemctl stop <서비스 이름> ★Nginx 설정 ------------------------------------------------------------------------------- ★★★ Nginx가 서버 정보를 노출하지 않도록설정 파일(/etc/nginx/nginx.conf)에서 server_tokens가 off로 설정되어 있는지 확인 server_tokens off; ------------------------------------------------------------------------------- ★★★ 접속 제한 동일한 IP에서의 과도한 요청을 제한 - 알맞게 조정 limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s; location / { limit_req zone=one burst=5; } ------------------------------------------------------------------------------- - 파일 업로드 크기 및 실행 제한 client_max_body_size 1M; location /uploads/ { location ~* \.(php|sh|pl|py|cgi)$ { deny all; } } ------------------------------------------------------------------------------- - HTTP 메서드 제한 location /uploads/ { limit_except GET POST { deny all; } } ------------------------------------------------------------------------------- - MIME 타입 필터링 location /uploads/ { autoindex off; # 디렉토리 목록 비활성화 default_type text/plain; # 기본 MIME 타입을 텍스트로 설정 } ★★★ 취약점 점검 툴 Nikto (웹 서버 취약점 스캐너) OWASP ZAP (Zed Attack Proxy) XSS, CSRF, SQL 인젝션과 같은 애플리케이션 취약점을 점검할 수 있는 도구 SQLMap을 사용하여 데이터베이스 취약점을 점검 ------------------------------------------------------------------------------- Fail2Ban : 비정상적인 로그인 시도를 감지하고 IP를 차단 sudo apt install fail2ban /etc/fail2ban/jail.local에서 Nginx 관련 규칙 추가 [nginx-http-auth] enabled = true filter = nginx-http-auth logpath = /var/log/nginx/error.log maxretry = 3 ------------------------------------------------------------------------------- 포트스캔 스캔후 불필요한 포트는 막기 sudo apt install nmap nmap -sS -sV <서버 IP> ------------------------------------------------------------------------------- ModSecurity 설치 sudo apt install libnginx-mod-security sudo systemctl restart nginx ------------------------------------------------------------------------------- ClamAV (악성코드 스캔) sudo apt install clamav sudo freshclam sudo clamscan -r /var/www/html ------------------------------------------------------------------------------- AppArmor를 활성화 서버의 프로세스가 악성 파일을 실행하지 못하도록 sudo apt install apparmor apparmor-utils sudo systemctl enable apparmor Nginx 프로필 확인 sudo aa-status ------------------------------------------------------------------------------- PHP.ini display_errors = Off log_errors = On error_log = /var/log/php_errors.log allow_url_fopen = Off allow_url_include = Off disable_functions = exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source 파일 업로드 제한 file_uploads = On upload_max_filesize = 1M post_max_size = 1M 원격파일 포함 차단 allow_url_fopen = Off allow_url_include = Off