README.md を更新
This commit is contained in:
209
README.md
209
README.md
@@ -1,3 +1,208 @@
|
|||||||
# redirect
|
# Nginx Redirect Helm Chart
|
||||||
|
|
||||||
Nginx Helm Chart specialized for Redirection
|
セキュアなAlpineベースのNginxリダイレクト専用サーバーのHelmチャートです。
|
||||||
|
|
||||||
|
## 特徴
|
||||||
|
|
||||||
|
- **セキュリティ重視**: 管理画面なし、読み取り専用ファイルシステム、非rootユーザー実行
|
||||||
|
- **3つのリダイレクトモード**: パス維持、ルートのみ、カスタムパス
|
||||||
|
- **完全な設定管理**: すべての設定をvalues.yamlで管理
|
||||||
|
- **高可用性**: Pod Disruption Budget、Anti-Affinity設定
|
||||||
|
- **Kubernetes標準**: Ingress自動統合
|
||||||
|
|
||||||
|
## インストール
|
||||||
|
|
||||||
|
```bash
|
||||||
|
helm install my-redirect ./nginx-redirect -f custom-values.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
## リダイレクトモード
|
||||||
|
|
||||||
|
### 1. パス維持モード (path-preserve)
|
||||||
|
|
||||||
|
元のパスを維持したまま新しいドメインにリダイレクトします。
|
||||||
|
|
||||||
|
**例**: `https://old-domain.com/products/item1` → `https://new-domain.com/products/item1`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
redirect:
|
||||||
|
mode: "path-preserve"
|
||||||
|
statusCode: 301
|
||||||
|
targetDomain: "https://new-domain.com"
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. ルートのみモード (root-only)
|
||||||
|
|
||||||
|
すべてのパスを無視して、指定したURLにリダイレクトします。
|
||||||
|
|
||||||
|
**例**: `https://old-domain.com/any/path` → `https://new-domain.com`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
redirect:
|
||||||
|
mode: "root-only"
|
||||||
|
statusCode: 301
|
||||||
|
targetDomain: "https://new-domain.com"
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. カスタムモード (custom)
|
||||||
|
|
||||||
|
個別のパスごとに異なる転送先を指定できます。
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
redirect:
|
||||||
|
mode: "custom"
|
||||||
|
statusCode: 301
|
||||||
|
customPaths:
|
||||||
|
- path: "/old-page"
|
||||||
|
target: "https://new-domain.com/new-page"
|
||||||
|
- path: "/products"
|
||||||
|
target: "https://shop.example.com/products"
|
||||||
|
- path: "/blog/*"
|
||||||
|
target: "https://blog.example.com"
|
||||||
|
fallbackTarget: "https://default-domain.com"
|
||||||
|
```
|
||||||
|
|
||||||
|
**パスの種類**:
|
||||||
|
- **固定パス**: `/old-page` → 完全一致
|
||||||
|
- **ワイルドカード**: `/blog/*` → `/blog/`以下のすべてのパスにマッチし、サブパスを保持
|
||||||
|
|
||||||
|
## セキュリティ機能
|
||||||
|
|
||||||
|
- **非rootユーザー実行**: UID/GID 101 (nginx)
|
||||||
|
- **読み取り専用ルートファイルシステム**
|
||||||
|
- **権限昇格の防止**
|
||||||
|
- **すべてのケーパビリティをドロップ**
|
||||||
|
- **Seccompプロファイル適用**
|
||||||
|
- **セキュリティヘッダー自動付与**
|
||||||
|
- X-Frame-Options
|
||||||
|
- X-Content-Type-Options
|
||||||
|
- X-XSS-Protection
|
||||||
|
- Referrer-Policy
|
||||||
|
|
||||||
|
## 設定例
|
||||||
|
|
||||||
|
### 例1: サイトリニューアルでドメイン変更
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
redirect:
|
||||||
|
mode: "path-preserve"
|
||||||
|
statusCode: 301
|
||||||
|
targetDomain: "https://new-company-site.com"
|
||||||
|
|
||||||
|
ingress:
|
||||||
|
hosts:
|
||||||
|
- host: old-company-site.com
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
pathType: Prefix
|
||||||
|
tls:
|
||||||
|
- secretName: old-site-tls
|
||||||
|
hosts:
|
||||||
|
- old-company-site.com
|
||||||
|
```
|
||||||
|
|
||||||
|
### 例2: ランディングページから特定URLへ
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
redirect:
|
||||||
|
mode: "root-only"
|
||||||
|
statusCode: 302
|
||||||
|
targetDomain: "https://campaign.example.com/special-offer"
|
||||||
|
|
||||||
|
ingress:
|
||||||
|
hosts:
|
||||||
|
- host: promo.example.com
|
||||||
|
```
|
||||||
|
|
||||||
|
### 例3: 複数サービスへの振り分け
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
redirect:
|
||||||
|
mode: "custom"
|
||||||
|
statusCode: 301
|
||||||
|
customPaths:
|
||||||
|
- path: "/shop/*"
|
||||||
|
target: "https://shop.example.com"
|
||||||
|
- path: "/blog/*"
|
||||||
|
target: "https://blog.example.com"
|
||||||
|
- path: "/support"
|
||||||
|
target: "https://help.example.com"
|
||||||
|
- path: "/contact"
|
||||||
|
target: "https://main-site.com/contact-us"
|
||||||
|
fallbackTarget: "https://main-site.com"
|
||||||
|
```
|
||||||
|
|
||||||
|
## HTTPステータスコード
|
||||||
|
|
||||||
|
- **301**: 恒久的なリダイレクト (推奨: SEO評価を引き継ぐ)
|
||||||
|
- **302**: 一時的なリダイレクト (推奨: テストやキャンペーン用)
|
||||||
|
|
||||||
|
## リソース要件
|
||||||
|
|
||||||
|
デフォルト設定:
|
||||||
|
- **CPU**: 50m (リクエスト) / 100m (上限)
|
||||||
|
- **メモリ**: 64Mi (リクエスト) / 128Mi (上限)
|
||||||
|
|
||||||
|
高トラフィック環境では調整してください:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpu: 200m
|
||||||
|
memory: 256Mi
|
||||||
|
requests:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 128Mi
|
||||||
|
```
|
||||||
|
|
||||||
|
## ヘルスチェック
|
||||||
|
|
||||||
|
`/health` エンドポイントで稼働状態を確認できます:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl http://your-domain.com/health
|
||||||
|
# 出力: healthy
|
||||||
|
```
|
||||||
|
|
||||||
|
## アップグレード
|
||||||
|
|
||||||
|
```bash
|
||||||
|
helm upgrade my-redirect ./nginx-redirect -f custom-values.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
## アンインストール
|
||||||
|
|
||||||
|
```bash
|
||||||
|
helm uninstall my-redirect
|
||||||
|
```
|
||||||
|
|
||||||
|
## トラブルシューティング
|
||||||
|
|
||||||
|
### リダイレクトが機能しない
|
||||||
|
|
||||||
|
1. Podのログを確認:
|
||||||
|
```bash
|
||||||
|
kubectl logs -l app.kubernetes.io/name=nginx-redirect
|
||||||
|
```
|
||||||
|
|
||||||
|
2. ConfigMapの内容を確認:
|
||||||
|
```bash
|
||||||
|
kubectl get configmap <release-name>-nginx-redirect -o yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Ingressの設定を確認:
|
||||||
|
```bash
|
||||||
|
kubectl describe ingress <release-name>-nginx-redirect
|
||||||
|
```
|
||||||
|
|
||||||
|
### SSL/TLS証明書の問題
|
||||||
|
|
||||||
|
cert-managerが正しく動作しているか確認:
|
||||||
|
```bash
|
||||||
|
kubectl get certificate
|
||||||
|
kubectl describe certificate nginx-redirect-tls
|
||||||
|
```
|
||||||
|
|
||||||
|
## ライセンス
|
||||||
|
|
||||||
|
MIT License
|
||||||
Reference in New Issue
Block a user