18
17

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ウェブサーバの基本設定-Apache

Posted at

Apache の基本設定

前回のNiktoを使った診断結果から、CentOSに含まれるApache HTTP Server をデフォルトのまま利用すると 攻撃者に対して多くの情報を提供してしまう。必要と思われる設定をまとめる。

Apache のバージョン情報を隠ぺい

Default

ServerTokens OS

以下に変更する

ServerTokens Prod

TRACE メソッドを無効にする

Cross-Site Tracing(XST)攻撃の対策として設定する。但し、現在はブラウザ側で対応されているため実害はない。

追記

ServerTokens Prod

確認方法 (Method Not Allowed になればOK)

# telnet localhost 80
Trying ::1...
Connected to localhost.
Escape character is '^]'.
TRACE /index.html HTTP/1.1
host: localhost

HTTP/1.1 405 Method Not Allowed 

PHPのバージョンを隠ぺい

/etc/php.ini

# vi /etc/php.ini
expose_php=On

     ↓変更
     
expose_php=Off

注)変更後は apache の再起動が必要となる

X-Frame-Optionsを無効

クリックジャッキング攻撃を防止するなどの目的で設定する。

追記

Header always append X-Frame-Options SAMEORIGIN

デフォルトの/icons/ /manual/等を非表示

Alias /icons/ "/var/www/icons/"

<Directory "/var/www/icons">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

       ↓ 変更

#Alias /icons/ "/var/www/icons/"

#<Directory "/var/www/icons">
#    Options Indexes MultiViews FollowSymLinks
#    AllowOverride None
#    Order allow,deny
#    Allow from all
#</Directory>

不必要なモジュールをロードしない

例)squirrelmail.conf を読み込まない設定

# cd /etc/httpd/conf.d
# mv squirrelmail.conf squirrelmail.conf.orig
# service httpd restart

ディレクトリの オプション Indexes には注意

ファイルの一覧が参照可能となる。 不必要な場合は Indexesを外す。

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

        ↓ 変更

<Directory "/var/www/html">
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
18
17
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
17

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?