Teksolvr
技術参照ハブに戻る

Apache Secure Configuration

安全なWebサーバー設定・構成コード参照ガイド

Webサーバー / CDN

Apache Secure Configuration

標準設定ファイル種別

Apache .htaccess configuration

セキュリティ監査の適用範囲

Apacheの.htaccessまたはhttpd.confを用いたセキュアな構成規則。SSLの強制、ディレクトリ一覧表示の禁止、およびセキュリティヘッダーの付与。

Webサーバー堅牢化の基本原則

Webサーバー層(Nginx, Apache)やエッジCDN(Cloudflare)での適切なセキュリティ設定の適用は、通信の盗聴や改ざん、情報漏洩を防ぐための最も重要かつ基本的な対策です。正しいリダイレクトの設定により平文通信を排除し、セキュリティヘッダーの付与により各種インジェクション攻撃を防止します。

設定コードの適用手順

Redirect HTTP to HTTPS via RewriteEngine

Force SSL redirection on Apache dynamically.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Disable Directory Indexing & Enable Headers

Disable indexes and append standard security header parameters.

# Disable directory index listing
Options -Indexes

# Configure Security Headers
<IfModule mod_headers.c>
  Header set X-Frame-Options "DENY"
  Header set X-Content-Type-Options "nosniff"
  Header set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
</IfModule>