templates/configmap.yaml を追加
This commit is contained in:
91
templates/configmap.yaml
Normal file
91
templates/configmap.yaml
Normal file
@@ -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 }}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user