diff --git a/templates/configmap.yaml b/templates/configmap.yaml index 98d861b..b3f1926 100644 --- a/templates/configmap.yaml +++ b/templates/configmap.yaml @@ -52,17 +52,30 @@ data: access_log off; } - # WordPressのパーマリンク対応 - location / { - try_files $uri $uri/ /index.php?$args; + # wp-adminディレクトリへのアクセス処理(重要) + location /wp-admin { + # wp-adminへのアクセスは必ず末尾スラッシュにリダイレクト + rewrite ^(/wp-admin)$ $1/ permanent; + + # wp-admin内のファイルを処理 + try_files $uri $uri/ /wp-admin/index.php?$args; } - # PHPファイルの処理 + # wp-includesディレクトリ(静的ファイル優先) + location /wp-includes { + try_files $uri $uri/ =404; + } + + # wp-contentディレクトリ(静的ファイル優先) + location /wp-content { + try_files $uri $uri/ =404; + } + + # PHPファイルの処理(最も重要) location ~ \.php$ { - # ファイルが存在しない場合は404 + # セキュリティ: cgi.fix_pathinfo=0 の代替 try_files $uri =404; - # FastCGI設定 fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; @@ -94,6 +107,13 @@ data: fastcgi_buffer_size 32k; } + # WordPressのパーマリンク対応(メインロケーション) + location / { + # 存在するファイル/ディレクトリ → そのまま配信 + # 存在しない → index.phpで処理(WordPressルーティング) + try_files $uri $uri/ /index.php?$args; + } + # 静的ファイルのキャッシュ location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|otf)$ { expires 1y; @@ -114,6 +134,11 @@ data: log_not_found off; } + # readme.html等の情報漏洩防止 + location ~* ^/(readme|license)\.(html|txt)$ { + deny all; + } + # XML-RPC DDoS対策(必要に応じてコメント解除) # location = /xmlrpc.php { # deny all;