From 3ba640c236993a631ea5d535e2dad11ae094d6c2 Mon Sep 17 00:00:00 2001 From: pieter Date: Sun, 15 Feb 2026 08:07:33 +0000 Subject: [PATCH] =?UTF-8?q?templates/configmap.yaml=20=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/configmap.yaml | 91 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 templates/configmap.yaml diff --git a/templates/configmap.yaml b/templates/configmap.yaml new file mode 100644 index 0000000..4ede08a --- /dev/null +++ b/templates/configmap.yaml @@ -0,0 +1,91 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "nginx-redirect.fullname" . }} + labels: + {{- include "nginx-redirect.labels" . | nindent 4 }} +data: + nginx.conf: | + user nginx; + worker_processes auto; + error_log /dev/stderr warn; + pid /tmp/nginx.pid; + + events { + worker_connections 1024; + } + + http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /dev/stdout main; + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + server_tokens off; + + # セキュリティヘッダー + add_header X-Frame-Options "DENY" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-XSS-Protection "1; mode=block" always; + add_header Referrer-Policy "strict-origin-when-cross-origin" always; + + # 一時ファイル用のディレクトリ設定 + client_body_temp_path /tmp/client_temp; + proxy_temp_path /tmp/proxy_temp_path; + fastcgi_temp_path /tmp/fastcgi_temp; + uwsgi_temp_path /tmp/uwsgi_temp; + scgi_temp_path /tmp/scgi_temp; + + server { + listen 8080; + server_name _; + + # ヘルスチェックエンドポイント + location /health { + access_log off; + return 200 "healthy\n"; + add_header Content-Type text/plain; + } + + {{- if eq .Values.redirect.mode "path-preserve" }} + # パス維持モード: パスをそのまま転送先に引き継ぐ + location / { + return {{ .Values.redirect.statusCode }} {{ .Values.redirect.targetDomain }}$request_uri; + } + {{- else if eq .Values.redirect.mode "root-only" }} + # ルートのみモード: 全てのパスを指定URLにリダイレクト + location / { + return {{ .Values.redirect.statusCode }} {{ .Values.redirect.targetDomain }}; + } + {{- else if eq .Values.redirect.mode "custom" }} + # カスタムモード: 個別パスごとに転送先を指定 + {{- range .Values.redirect.customPaths }} + {{- if hasSuffix "/*" .path }} + # ワイルドカードパス: {{ .path }} + location ~ ^{{ trimSuffix "/*" .path }}(/.*)?$ { + return {{ $.Values.redirect.statusCode }} {{ .target }}$1; + } + {{- else }} + # 固定パス: {{ .path }} + location = {{ .path }} { + return {{ $.Values.redirect.statusCode }} {{ .target }}; + } + {{- end }} + {{- end }} + + # フォールバック: 設定にないパスへのアクセス + location / { + return {{ .Values.redirect.statusCode }} {{ .Values.redirect.fallbackTarget }}; + } + {{- end }} + } + } \ No newline at end of file