워드프레스로 만든 웹사이트의 게시판에 사진을 업로드 하는 중에 발생했다.
Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request.Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.More information about this error may be available in the server error log. |
게시판에 올려야 할 사진이 대충 400장 이상인데....잘 올라가다가 특정 파일을 올릴 때 오류가 발생했다. 아파치 로그에서 아래와 같은 메시지를 확인할 수 있었다.
ModSecurity: Access denied with code 44 (phase 2). Match of "eq 0" against "MULTIPART_UNMATCHED_BOUNDARY" required. [file "/etc/httpd/conf.d/mod_security.conf"] [line "34"] [id "200003"] [msg "Multipart parser detected a possible unmatched boundary."] [hostname ~~~~
[http:error] [pid 9893] [client ip-address] AH01579: Invalid response status 44, referer: https://~~~~
mod_security.conf의 34번째 줄 [id '200003'].
1 <IfModule mod_security2.c>
2 # ModSecurity Core Rules Set configuration
3 IncludeOptional modsecurity.d/*.conf
4 IncludeOptional modsecurity.d/activated_rules/*.conf
5
6 # Default recommended configuration
7 SecRuleEngine On
8 SecRequestBodyAccess On
9 SecRule REQUEST_HEADERS:Content-Type "text/xml" \
10 "id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=XML"
11 SecRequestBodyLimit 13107200
12 SecRequestBodyNoFilesLimit 131072
13 SecRequestBodyInMemoryLimit 131072
14 SecRequestBodyLimitAction Reject
15 SecRule REQBODY_ERROR "!@eq 0" \
16 "id:'200001', phase:2,t:none,log,deny,status:400,msg:'Failed to parse request body.',logdata:'%{reqbody_error_msg}',severity:2"
17 SecRule MULTIPART_STRICT_ERROR "!@eq 0" \
18 "id:'200002',phase:2,t:none,log,deny,status:44,msg:'Multipart request body \
19 failed strict validation: \
20 PE %{REQBODY_PROCESSOR_ERROR}, \
21 BQ %{MULTIPART_BOUNDARY_QUOTED}, \
22 BW %{MULTIPART_BOUNDARY_WHITESPACE}, \
23 DB %{MULTIPART_DATA_BEFORE}, \
24 DA %{MULTIPART_DATA_AFTER}, \
25 HF %{MULTIPART_HEADER_FOLDING}, \
26 LF %{MULTIPART_LF_LINE}, \
27 SM %{MULTIPART_MISSING_SEMICOLON}, \
28 IQ %{MULTIPART_INVALID_QUOTING}, \
29 IP %{MULTIPART_INVALID_PART}, \
30 IH %{MULTIPART_INVALID_HEADER_FOLDING}, \
31 FL %{MULTIPART_FILE_LIMIT_EXCEEDED}'"
32
33 SecRule MULTIPART_UNMATCHED_BOUNDARY "!@eq 0" \
34 "id:'200003',phase:2,t:none,log,deny,status:44,msg:'Multipart parser detected a possible unmatched boundary.'"
35
36 SecPcreMatchLimit 1000
37 SecPcreMatchLimitRecursion 1000
38
39 SecRule TX:/^MSC_/ "!@streq 0" \
40 "id:'200004',phase:2,t:none,deny,msg:'ModSecurity internal error flagged: %{MATCHED_VAR_NAME}'"
41
42 SecResponseBodyAccess Off
43 SecDebugLog /var/log/httpd/modsec_debug.log
44 SecDebugLogLevel 0
45 SecAuditEngine RelevantOnly
46 SecAuditLogRelevantStatus "^(?:5|4(?!04))"
47 SecAuditLogParts ABIJDEFHZ
48 SecAuditLogType Serial
49 SecAuditLog /var/log/httpd/modsec_audit.log
50 SecArgumentSeparator &
51 SecCookieFormat 0
52 SecTmpDir /var/lib/mod_security
53 SecDataDir /var/lib/mod_security
54 </IfModule>
대충 테스트 해보니 파일의 이름이나 php의 업로드 용량 제한문제는 아닌 듯 하다.
급한대로(?) line 33~34를 주석처리 하면 오류가 사라진다.
또는
SecRuleRemoveById 200003 을 mod_security.conf에 추가해도 된다. </IfModule> 바로 윗 줄에 추가하면 될 것이다.
문제가 발생하는 룰을 제거하는 것으로 일단은 오류 발생은 안하고 있지만...
나중에 다시 한 번 봐야할 것 같다. mod_security를 최신버전으로 다시 설치하면 어떨까????
Mod Security 관련글....
2021.12.24 - [Linux/Web Server] - 413 Request Entity Too Large [modsecurity & apache]
413 Request Entity Too Large [modsecurity & apache]
서버오류..... 서버에 파일을 업로드 할 때 발생했다면 대게는 업로드 할 수 있는 파일 용량의 한계를 넘겼기 때문이겠지만 워드프레스로 사이트를 제작하는 도중에 '저장하기'나 '업데이트'를
aegypius.tistory.com
2021.12.10 - [Linux/TIP] - 악성bot 차단하기 (feat. mj12bot.com/majestic12)
악성bot 차단하기 (feat. mj12bot.com/majestic12)
가끔 apache의 log를 보면 눈에 띄는 녀석이 있다. MJ12bot과 SemrushBot이다. 대충 웹 검색을 해보니 semrush는 robots.txt도 무시하고 접근한다고 하는데....robots.txt를 이용해서 사이트별로 특정 봇에 대한..
aegypius.tistory.com
2021.08.22 - [Linux/Web Server] - 업로드 파일의 용량 제한 변경하기(feat. ModSecurity)
업로드 파일의 용량 제한 변경하기(feat. ModSecurity)
워드프레스의 미디어 라이브러리에 파일을 업로드 하는데 계속 오류가 발생한다. 분명 php.ini에서 업로드 할 수 있는 최대 파일용량은 아래와 같이 8GB로 설정했는데.... ..... post_max_size = 8192M .....
aegypius.tistory.com
ModSecurity: Access denied with code 44 (phase 2). Match of "eq 0" against "MULTIPART_UNMATCHED_BOUNDARY"
워드프레스로 만든 웹사이트의 게시판에 사진을 업로드 하는 중에 발생했다. Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete you..
aegypius.tistory.com
2021.04.21 - [Linux/Web Server] - 웹 서버의 정보 숨기기 (apache)
웹 서버의 정보 숨기기 (apache)
웹서버보안 : hide apache webserver information & mod_security curl, nc, httprint 등으로 서버의 정보를 수집하는 방법은 다양하다. 도메인이나 ip주소를 입력하면 해당 서버의 OS, 웹서버, 네임서버 등의 정..
aegypius.tistory.com
'Linux > Web Server' 카테고리의 다른 글
413 Request Entity Too Large [modsecurity & apache] (0) | 2021.12.24 |
---|---|
업로드 파일의 용량 제한 변경하기(feat. ModSecurity) (0) | 2021.08.22 |
apache - HTTP 30x [URL Redirection] (0) | 2021.06.07 |
웹 서버의 정보 숨기기 (apache) (2) | 2021.04.21 |
[CentOS8] httpd[proxy_fcgi:error] [pid 31nn:tid 14nn] ~ AH01071: Got error 'Primary script unknown' (0) | 2020.12.13 |
댓글