From 601c2d3eb3281b37a48428efff3a84e1ffc77b4a Mon Sep 17 00:00:00 2001 From: pieter Date: Mon, 15 Dec 2025 06:36:28 +0000 Subject: [PATCH] =?UTF-8?q?templates/configmap.yaml=20=E3=82=92=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/configmap.yaml | 50 +++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/templates/configmap.yaml b/templates/configmap.yaml index 15e198d..a266196 100644 --- a/templates/configmap.yaml +++ b/templates/configmap.yaml @@ -25,7 +25,7 @@ data: server_name _; root /var/www/html; - index index.php; + index index.php index.html; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; @@ -49,31 +49,59 @@ data: access_log off; } - # templates/configmap.yaml の nginx.conf セクション + # WordPressのパーマリンク対応 location / { try_files $uri $uri/ /index.php?$args; } - # WordPress管理画面用の設定 - location ~ ^/(wp-admin|wp-login\.php) { - try_files $uri $uri/ /index.php?$args; - } - # PHPファイルの処理 location ~ \.php$ { + # ファイルが存在しない場合は404 try_files $uri =404; + + # FastCGI設定 fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass 127.0.0.1:9000; # または wordpress コンテナのサービス名 + fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; + + # FastCGIパラメータの読み込み include fastcgi_params; + + # 重要: これらのパラメータを正しく設定 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; + + # HTTPS対応 + fastcgi_param HTTPS $fastcgi_https if_not_empty; + + # タイムアウト設定 + fastcgi_read_timeout 300; + fastcgi_send_timeout 300; + fastcgi_connect_timeout 300; + + # バッファ設定 + fastcgi_buffers 16 16k; + fastcgi_buffer_size 32k; } - # 静的ファイルのキャッシュ設定(オプション) - location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { - expires max; + # 静的ファイルのキャッシュ + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|otf)$ { + expires 1y; + add_header Cache-Control "public, immutable"; log_not_found off; access_log off; } + + # wp-config.phpへの直接アクセス拒否 + location ~* /wp-config\.php { + deny all; + } + + # 隠しファイルへのアクセス拒否 + location ~ /\. { + deny all; + access_log off; + log_not_found off; + } } \ No newline at end of file