作業日記@HatenaBlog

各種の作業メモ

Apacheの情報を隠す

外部から Apache の情報を知られるのを防ぐ。

httpd-default.conf を有効にする。(コメントアウトを外す)

# cd /usr/local/etc/apache22/
# vi httpd.conf
 
#Include etc/apache22/extra/httpd-default.conf
↓
Include etc/apache22/extra/httpd-default.conf

httpd-default.conf を書き換える。

# cd /usr/local/etc/apache22/extra/
# vi httpd-default.conf
 
ServerTokens Full
↓
ServerTokens Prod ←変更(サーバーの情報を隠す)
 
ServerSignature On
↓
ServerSignature Off ←変更(Apacheのバージョン情報を隠す)
 
 
# /usr/local/etc/rc.d/apache22 restart
# /usr/local/etc/rc.d/apache22 reload

TRACE メソッドを無効にする

Apache のセキュリティを向上させるため TRACE メソッドを無効にする。

設定前
# telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
TRACE / HTTP/1.0 ←TRACE コマンド
 
HTTP/1.1 200 OK ←受付OK
Date: Sun, 01 Jan 20xx HH:MM:SS GMT
Server: Apache
Connection: close
Content-Type: message/http
 
TRACE / HTTP/1.0
 
Connection closed by foreign host.
設定追加
# cd /usr/local/etc/apache22/Includes/
# vi httpd-secure.conf
TraceEnable Off
 
# /usr/local/etc/rc.d/apache22 restart
# /usr/local/etc/rc.d/apache22 reload
設定後
# telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
TRACE / HTTP/1.0
 
HTTP/1.1 405 Method Not Allowed ←受付NG
Date: Sun, 01 Jan 20xx HH:MM:SS GMT
Server: Apache
Allow:
Content-Length: 223
Connection: close
...
Connection closed by foreign host.

外部から telnet コマンドで Apache のバージョンを知る

# telnet hogehoge.com 80
GET / HTTP/1.0 と打って、Enterを2回押す
 
HTTP/1.1 200 OK
Date: Sun, 01 Jan 20xx HH:MM:SS GMT
Server: Apache/2.0.45 (Unix)
Content-Location: index.html.en
...

 

Apache の設定変更後は reload する

設定ファイルを変更後に

# /usr/local/etc/rc.d/apache22 restart

したところ、うまく設定が反映されるログファイルが出力されない不具合が発生した。
このサイトを参考に

# /usr/local/etc/rc.d/apache22 reload

したところ正常動作するようになった。