自宅サーバー Fedora (Home) » Apache HTTP Server で Web サーバー構築 » Apache HTTP Server 2.2 »  Apache のセキュリティー設定

Apache のセキュリティー設定

Apache 設定ファイル httpd.conf を使った基本的なセキュリティー対策を行います。
ディレクトリに対する設定、ユーザーディレクトリに対する設定、サーバー応答ヘッダー情報の設定、エラーメッセージやフッターに表示される情報の設定などを行います。

ディレクトリの設定

URL を使ってアクセスできる全てのファイルを閲覧できないように設定します。
同時にシンボリックリンクを辿ったアクセスの禁止設定も行います。

# vi /usr/local/httpd/conf/httpd.conf
/usr/local/httpd/conf/httpd.conf
#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the ”default” to be a very restrictive set of
# features.
#
#<Directory />デフォルトの設定
#    Options FollowSymLinks
#    AllowOverride None
#    Order deny,allow
#    Deny from all
#</Directory>
<Directory />システム全体のアクセス制御
    Options None
    AllowOverride None
    Order allow,deny
    Deny from all
</Directory>

ユーザー専用ディレクトリの設定

UserDir ディレクティブを使ってユーザーのドキュメントへのリクエストを受けた時に使うユーザーのホームディレクトリーの設定を行うことができます。
Apache の設定ファイル httpd.conf を編集して設定ファイル extra/httpd-userdir.conf を読み込むように設定します。

# vi /usr/local/httpd/conf/httpd.conf
/usr/local/httpd/conf/httpd.conf
# User home directories
Include conf/extra/httpd-userdir.confコメントアウトされている行を有効にする

extra/httpd-userdir.conf ファイルを編集してユーザー専用ディレクトリの設定を行います。

# vi /usr/local/httpd/conf/extra/httpd-userdir.conf
/usr/local/httpd/conf/extra/httpd-userdir.conf
#UserDir public_htmlデフォルトの設定
#UserDir enabled user1 user2 user3許可するユーザーが決まっている場合
UserDir disabledユーザー専用ディレクトリを無効にする場合

サーバー情報の隠蔽

クライアントに送り返す Server 応答ヘッダー内にサーバの一般的な OS 種別やコンパイルされて組み込まれているモジュールの情報などを含めずに、Web サーバーの名前だけを与えるように設定します。
またサーバーが生成するドキュメントのフッターやエラーメッセージにサーバーの情報を表示しないように設定します。
Apache の設定ファイル httpd.conf を編集して設定ファイル extra/httpd-default.conf を読み込むように設定します。

# vi /usr/local/httpd/conf/httpd.conf
/usr/local/httpd/conf/httpd.conf
# Various default settings
Include conf/extra/httpd-default.confコメントアウトされている行を有効にする

extra/httpd-default.conf ファイルを編集して環境設定を行います。

# vi /usr/local/httpd/conf/extra/httpd-default.conf
/usr/local/httpd/conf/extra/httpd-default.conf
#
# ServerTokens
# This directive configures what you return as the Server HTTP response
# Header. The default is ’Full’ which sends information about the OS-Type
# and compiled in modules.
# Set to one of:  Full | OS | Minor | Minimal | Major | Prod
# where Full conveys the most information, and Prod the least.
#
#ServerTokens Full
ServerTokens Prodクライアントに送るサーバーの情報を最小限に抑える

#
# Optionally add a line containing the server version and virtual host
# name to server-generated pages (internal error documents, FTP directory
# listings, mod_status and mod_info output etc., but not CGI generated
# documents or custom error documents).
# Set to ”EMail” to also include a mailto: link to the ServerAdmin.
# Set to one of:  On | Off | EMail
#
#ServerSignature On
ServerSignature Offフッターおよび mailto: 参照を作成しない

TRACEメソッドの無効化

Basic 認証の ID とパスワードが漏洩する XST(Cross-Site Tracing)を回避するために TraceEnable ディレクティブの設定を行います。
extra/httpd-default.conf に以下の行を追加します。

# vi /usr/local/httpd/conf/extra/httpd-default.conf
/usr/local/httpd/conf/extra/httpd-default.conf
TraceEnable Off

Apache の再起動

Apache の設定ファイルを変更した後は Apache を再起動する必要があります。

# /usr/local/httpd/bin/apachectl graceful
カテゴリー
  • Fedora のインストール (24)
  • OpenSSH で SSH サーバー構築 (4)
  • NTP で時刻情報サーバー構築 (4)
  • Apache HTTP Server で Web サーバー構築 (32)
  • MySQL でデーターベースサーバー構築 (10)
  • PostgreSQL でデーターベースサーバー構築 (22)
  • PHP で Web アプリケーションサーバー構築 (4)
  • qmail でメールサーバー構築 (7)
  • Tomcat で Web アプリケーションサーバー構築 (3)
  • Samba でファイルサーバー構築 (3)
  • BIND でネームサーバー構築 (3)
  • ProFTPD で FTP サーバー構築 (5)
  • snort でネットワーク進入探知システム構築 (3)
  • CMS でサイト構築 (3)
  • ネットワーク設定 (3)
  • システム設定 (4)
  • ライブラリのインストール (8)
  • Debian GNU/Linux (26)
  • Ubuntu (17)
  • メモ (6)
  • このサイトについて (4)
  • 相互リンク (6)