"HTTP 404 페이지 아파치 버전 숨기기"의 두 판 사이의 차이

65번째 줄: 65번째 줄:
==같이 보기==
==같이 보기==
*[[아파치 ServerTokens Prod, ServerSignature Off]]
*[[아파치 ServerTokens Prod, ServerSignature Off]]
*[[HTTP 헤더 아파치 버전 정보 숨기기]]
*[[HTTP 헤더 아파치 버전 숨기기]]
*[[/etc/httpd/conf/httpd.conf]]
*[[/etc/httpd/conf/httpd.conf]]
*[[아파치 디렉토리 브라우징 막기]]
*[[아파치 디렉토리 브라우징 막기]]

2014년 9월 6일 (토) 23:28 판

Hiding Apache Version Information on Errors
HTTP 404 Not Found 아파치 버전 숨기기
ServerSignature Off

1 문제 상황

  • 404 Not Found 페이지에서 아파치 버전과 OS 정보가 노출된다.
  • 이것을 숨기고 싶다.
[root@jmnote ~]# curl http://localhost/asdfasdf
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /not_found.php was not found on this server.</p>
<hr>
<address>Apache/2.2.3 (CentOS) Server at localhost Port 80</address>
</body></html>
→ 아파치 버전은 2.2.3, OS는 CentOS임이 표시됨

2 확인

[root@jmnote ~]# cat /etc/httpd/conf/httpd.conf | grep ServerSignature On
→ 서버 정보를 표시하게 되어 있음. 이게 기본값

3 변경

  • 아파치 설정파일 httpd.conf를 httpd.conf_old로 복사하여 보존
[root@jmnote ~]# cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf_old
  • sed를 이용하여 ServerSignature On을 Off로 치환[1]
[root@jmnote ~]# sed -i "s/ServerSignature On/ServerSignature Off/g" /etc/httpd/conf/httpd.conf
[root@jmnote ~]# diff /etc/httpd/conf/httpd.conf_old /etc/httpd/conf/httpd.conf
537c537
< ServerSignature On
---
> ServerSignature Off
→ ServerSignature 가 Off로 변경됨
  • 새 설정을 적용하기 위해 아파치 재시작
[root@jmnote ~]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

4 확인 2

[root@jmnote ~]# curl http://localhost/asdfasdf
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /not_found.php was not found on this server.</p>
</body></html>
→ address 태그 부분이 완전히 사라졌다. 아파치/OS 정보가 노출되지 않음

5 같이 보기

6 주석

  1. sed 대신 vi로 직접 편집해도 된다.
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}