feat: チャートをゼロから再設計(外部DB前提のYOURLS+Nginx構成に作り直し)
Helm Chart Release / release-chart (push) Successful in 7s
Helm Chart Release / release-chart (push) Successful in 7s
旧チャートは存在しないDocker Hubイメージ(yourls/yourls)を参照し、Bitnami MySQL サブチャートに依存するなど正しく動作しない状態だったため、YOURLS公式イメージ (docker.io/yourls, container-entrypoint.sh/config-container.php)の実装を確認した上で WordPressチャートと同一方針(外部DB、emptyDir+PVC分離、fsGroup非root実行、 real IP取得対応)でスクラッチから再構築した。
This commit is contained in:
+89
-23
@@ -6,51 +6,117 @@ metadata:
|
||||
{{- include "yourls-nginx.labels" . | nindent 4 }}
|
||||
data:
|
||||
default.conf: |
|
||||
upstream php-fpm {
|
||||
server localhost:9000;
|
||||
upstream php {
|
||||
server 127.0.0.1:9000;
|
||||
}
|
||||
|
||||
{{- if .Values.nginx.forwardRealIP.enabled }}
|
||||
# 実IPアドレスの抽出(X-Forwarded-Forから最初のIPを取得)
|
||||
map $http_x_forwarded_for $real_ip {
|
||||
~^(\d+\.\d+\.\d+\.\d+) $1;
|
||||
default $remote_addr;
|
||||
}
|
||||
{{- end }}
|
||||
|
||||
# HTTPSプロトコルの判定
|
||||
map $http_x_forwarded_proto $fastcgi_https {
|
||||
default '';
|
||||
https on;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
root /var/www/html;
|
||||
index index.php index.html;
|
||||
# ルート直下は yourls-loader.php が、/admin/ 配下は admin/index.php がエントリポイント。
|
||||
# ディレクトリ末尾スラッシュでのアクセス(例: /admin/)を両方とも正しく解決するため
|
||||
# 2つ指定する(存在する方が使われる)。
|
||||
index yourls-loader.php index.php;
|
||||
|
||||
client_max_body_size 100M;
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
client_max_body_size 10M;
|
||||
|
||||
{{- if .Values.nginx.forwardRealIP.enabled }}
|
||||
# 信頼できるプロキシからのX-Forwarded-Forヘッダーを使用
|
||||
real_ip_header X-Forwarded-For;
|
||||
{{- range .Values.nginx.forwardRealIP.trustedProxies }}
|
||||
set_real_ip_from {{ . }};
|
||||
{{- end }}
|
||||
real_ip_recursive on;
|
||||
{{- end }}
|
||||
|
||||
# DB接続情報等を保持する設定ファイルへの直接アクセスを拒否
|
||||
# (通常はfastcgiで.phpとして実行されるため到達しないが、多層防御として明示的に拒否する)
|
||||
location = /user/config.php {
|
||||
deny all;
|
||||
}
|
||||
|
||||
# 内部処理用ファイル群(直接リクエストされることを想定しない)へのアクセスを拒否
|
||||
location ^~ /includes/ {
|
||||
deny all;
|
||||
}
|
||||
|
||||
# 隠しファイルへのアクセス拒否
|
||||
location ~ /\. {
|
||||
deny all;
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
}
|
||||
|
||||
# 短縮URLのリダイレクト・favicon/robots.txt・管理画面を含む全ての動的処理は
|
||||
# yourls-loader.php が担う(favicon.ico/robots.txtは物理ファイルが存在しないため、
|
||||
# ここで意図的にPHPへフォールバックさせて動的応答させる)
|
||||
location / {
|
||||
try_files $uri $uri/ /yourls-loader.php$is_args$args;
|
||||
}
|
||||
|
||||
# PHPファイルの処理
|
||||
location ~ \.php$ {
|
||||
try_files $uri =404;
|
||||
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass php-fpm;
|
||||
fastcgi_pass php;
|
||||
fastcgi_index index.php;
|
||||
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_buffering off;
|
||||
fastcgi_read_timeout 300;
|
||||
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
|
||||
|
||||
# HTTPS判定をPHP側に伝える
|
||||
fastcgi_param HTTPS $fastcgi_https if_not_empty;
|
||||
|
||||
{{- if .Values.nginx.forwardRealIP.enabled }}
|
||||
# プロキシ経由のリクエスト情報をPHPに伝える(リアルIP取得有効時)
|
||||
fastcgi_param HTTP_X_FORWARDED_PROTO $http_x_forwarded_proto;
|
||||
fastcgi_param HTTP_X_FORWARDED_FOR $http_x_forwarded_for;
|
||||
fastcgi_param REMOTE_ADDR $real_ip;
|
||||
{{- else }}
|
||||
fastcgi_param HTTP_X_FORWARDED_PROTO $http_x_forwarded_proto;
|
||||
fastcgi_param HTTP_X_FORWARDED_FOR $http_x_forwarded_for;
|
||||
fastcgi_param REMOTE_ADDR $remote_addr;
|
||||
{{- end }}
|
||||
|
||||
fastcgi_read_timeout 60;
|
||||
fastcgi_send_timeout 60;
|
||||
fastcgi_connect_timeout 60;
|
||||
|
||||
fastcgi_buffers 16 16k;
|
||||
fastcgi_buffer_size 32k;
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
|
||||
location = /favicon.ico {
|
||||
# 静的ファイルのキャッシュ
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
expires 7d;
|
||||
add_header Cache-Control "public";
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location = /robots.txt {
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
allow all;
|
||||
}
|
||||
|
||||
location ~* \.(css|gif|ico|jpeg|jpg|js|png|svg|woff|woff2|ttf|eot)$ {
|
||||
expires max;
|
||||
log_not_found off;
|
||||
}
|
||||
}
|
||||
{{- with .Values.nginx.extraConfig }}
|
||||
{{- . | nindent 8 }}
|
||||
{{- end }}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user