Server & OS

우분투 아파치 버전 정보 숨기기

페이지 정보

본문

확인[편집]

  • 기본값은 ServerSignature On
  • 서버 정보를 표시하게 되어 있음
CentOS
[root@zetawiki ~]# cat /etc/httpd/conf/httpd.conf | grep ServerSignature
ServerSignature On
우분투
root@zetawiki:~# cat /etc/apache2/conf-enabled/security.conf | grep ServerSignature
#ServerSignature Off
ServerSignature On

변경[편집]

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

확인 2[편집]

[root@zetawiki ~]# 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 정보가 노출되지 않음

 

 




 

문제 상황[편집]

  • HTTP 헤더에 아파치 버전, OS 정보가 노출된다.
  • 이것을 숨기고 싶다.
[root@zetawiki ~]# curl -I http://localhost
HTTP/1.1 200 OK
Date: Sat, 06 Sep 2014 23:18:46 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.3.3
Connection: close
Content-Type: text/html; charset=UTF-8
→ 아파치 버전은 2.2.15, OS는 CentOS임이 표시됨

아파치 설정 확인[편집]

[root@zetawiki ~]# grep ServerTokens /etc/httpd/conf/httpd.conf
ServerTokens OS

변경[편집]

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

결과 확인[편집]

[root@zetawiki ~]# curl -I http://localhost
HTTP/1.1 200 OK
Date: Sat, 06 Sep 2014 23:28:42 GMT
Server: Apache
X-Powered-By: PHP/5.3.3
Connection: close
Content-Type: text/html; charset=UTF-8
→ 아파치 버전과 OS 정보가 보이지 않는다.

관련자료

등록된 댓글이 없습니다.
Today's proverb
우리의 꿈은, 뒤에 오는 사람들이 우리를 딛고 우리 위에서 이루게 하는 것입니다. 나는 평생을 창조적인 작업을 위해서 살아왔습니다. 누가 하라고 해서 한 것이 아니라 그것이 나의 삶 그 자체의 즐거움이었기 때문입니다. 현실을 직시하며 현재의 수준을 유지하라. 그리고 더 먼 곳을 향하는 시야를 가져라.