---
id: atlas-domain
name: Atlas ドメイン接続（atlas-financials.jp）
category: 自社・運用基盤
status: ✅ 完了
priority: ★ 通常（完了済み）
updated: 2026-04-13
---

# Atlas ドメイン接続（atlas-financials.jp）

## 📝 概要
`atlas-financials.jp` ドメインでAtlasブランドの全サービスを公開するプロジェクト。2週間にわたるGitHub Pagesのトラブルを経て、最終的にCloudflare Pages/Workersに移行して解決。

---

## 📜 全体タイムライン

```
2026-03-25  CNAME削除（reports→ルートサイトに移動）→ ビルドエラー連発の起点
     ↓  約2週間、サイトが404のまま放置
2026-04-10  本格調査開始（Session 1）
2026-04-12  ドメイン検証・GitHub Actionsブロック発見・Cloudflare移行開始（Session 2）
2026-04-13  Cloudflare移行完了・全サービス稼働確認（Session 3）
```

---

## Phase 1: GitHub Pages での構築試行（2026-04-10〜04-12）

### 1.1 初期診断

**発見した問題:**

| # | 問題 | 原因 |
|---|---|---|
| 1 | ルートサイト 404 | `atlasfinancials.github.io` リポジトリのビルドエラー |
| 2 | ドメイン未検証 | `protected_domain_state: "unverified"` |
| 3 | HTTPS未強制 | `https_enforced: false` |
| 4 | reports/ パス衝突 | ルートサイトに `reports/NKE/` が残存 |
| 5 | deploy_report.py URL不整合 | `yskzz121.github.io` を参照 |

**根本原因チェーン:**
```
CNAME削除 (3/25) → reportsビルドエラー → ルートサイトもビルドエラー
   → 全てqueuedのまま停止 → GitHub Actionsが無効化されていた
```

### 1.2 解決した問題

#### reports/ ディレクトリ衝突 → ✅
- `atlasfinancials.github.io` リポジトリに `reports/NKE/FY26Q3.html` 等が残留
- `reports` リポジトリ（`/reports/` パス）と衝突していた
- 削除してコミット・プッシュ

#### ドメイン検証（Unverified → Verified）→ ✅

**エラー:** 「We couldn't find the TXT record」が繰り返し発生

**原因1: TXTレコード値の不一致**
- DNSに設定されていた値: `9f82ce7cb4a89ce77cea97ff888d3d`
- GitHubが期待していた値: `9f82ce7cb4a89ce77cea97f1f888d2d`
- 末尾の数文字が微妙に異なっていた（以前の古い検証コードが残存）

**原因2: Verifyボタンを押すたびにコードが再発行される**
- Verify失敗 → 新コード発行 → DNSに古いコードが残る → また失敗、のループ
- **解決策:** DNS反映を `dig` コマンドで確認してからVerifyを押す順序に変更

**原因3: お名前.comのDNS反映遅延**
- 管理画面で「設定完了」と表示されても、権威サーバーへの反映に数分かかる
- `dig TXT ... @01.dnsv.jp +short` で権威サーバーに直接問い合わせて確認

**最終的な解決手順:**
```
1. GitHubの検証画面でコードをコピー
2. お名前.comでTXTレコードを更新
3. dig で権威サーバーへの反映を確認（30秒間隔で監視）
4. 反映確認後、GitHubでVerifyをクリック
→ Successfully verified atlas-financials.jp
```

#### HTTPS強制 → ✅
```bash
gh api repos/AtlasFinancials/atlasfinancials.github.io/pages -X PUT -F https_enforced=true
```

#### deploy_report.py URL更新 → ✅
```python
# 旧
PAGES_BASE_URL = f"https://{GITHUB_USERNAME}.github.io/{REPO_NAME}"
# 新
PAGES_BASE_URL = "https://atlas-financials.jp/reports"
```

### 1.3 解決できなかった問題: GitHub Actionsブロック

**症状:**
- Actionsタブに「GitHub Actions is currently disabled for your account. Please reach out to GitHub Support for assistance.」
- 全Pages ビルドが `queued` のまま実行されない（13件滞留）
- キャンセルも不可（API: 500エラー、ブラウザ: 「Failed to cancel workflow」）

**調査結果:**
- 支払い情報は正常（GitHub Team $4/月、AmEx登録済み、直近支払い成功）
- Actions minutes: 0 min used / 3,000 min included（枠は余っている）
- Org設定の Actions permissions: 「Allow all actions and reusable workflows」（正常）
- **原因不明** — GitHub側でアカウントレベルで無効化されている

**対応:**
- GitHub Supportにチケット提出（2026-04-12、Stuck workflow カテゴリ）

---

## Phase 2: 新Org（AtlasFinancialsJP）での回避試行（2026-04-12）

**仮説:** Org固有の問題なら、新Orgで回避できるはず

**実行:**
1. 新Org `AtlasFinancialsJP` を作成（Free プラン）
2. リポジトリ（`atlasfinancialsjp.github.io` / `reports`）を新Orgにpush
3. ドメイン検証 Verified 達成（TXTレコードをAtlasFinancialsJPに更新）

**結果: ❌ 新Orgでも同じActionsブロックが発生**

**学び:** Actionsの無効化は **Orgレベルではなくアカウントレベル** の制限。同じ `yskzz121` アカウントが所有者である限り、どのOrgでも同じ制限を受ける。

---

## Phase 2.5: 個人アカウントでの回避試行（2026-04-12）

**仮説:** 個人アカウント（yskzz121）のPagesなら動くかもしれない

**実行:**
1. `yskzz121/atlas-landing` リポジトリを作成
2. LPファイルをpush → Pages有効化

**結果: ❌ カスタムドメイン設定時にエラー**
- 「You must verify your domain atlas-financials.jp before being able to use it.」
- ドメインが `AtlasFinancials` orgで検証済みのため、個人アカウントでは使用不可
- GitHubの仕様: 1つのドメインは1つのアカウント/orgでしか検証・使用できない

**対応:** リポジトリ削除

---

## Phase 3: Cloudflare Pages/Workers への移行（2026-04-12〜04-13）

GitHub Actionsに依存しないホスティングに方針転換。

### 3.1 Cloudflareアカウント作成・初期デプロイ

1. Cloudflareアカウント作成（y.uema@uemabento.com）
2. GitHub連携（AtlasFinancialsJP orgのリポジトリにアクセス許可）
3. ルートサイトをCloudflare Workers にデプロイ
   - **注意:** Cloudflareダッシュボードの「Workers and Pages」でPagesとWorkersのUIが紛らわしい。「Create a Worker」ではなく「Pages」タブを選ぶこと
4. 動作確認: `atlasfinancialsjp.y-uema.workers.dev` → **200 OK**

### 3.2 ドメイン追加・ネームサーバー変更

1. Cloudflareにドメイン `atlas-financials.jp` を追加（Free プラン）
2. DNSレコードの自動スキャン（Aレコード4件 + CNAME 1件を検出）
3. お名前.comでネームサーバーを変更:
   - 旧: 01〜04.dnsv.jp
   - 新: chuck.ns.cloudflare.com / sara.ns.cloudflare.com
4. NS反映待ち（約12時間で反映完了）

### 3.3 カスタムドメイン設定エラーと解決

**エラー:** 「This domain is already in use. Please delete the corresponding record in DNS settings」

**原因:** Cloudflareが旧GitHub PagesのAレコード（185.199.x.x）を自動インポートしていた。これがWorkerのカスタムドメイン設定をブロック。

**解決:** Cloudflare DNS → Records で以下を全削除:
- A 185.199.108.153 〜 185.199.111.153（4件）
- CNAME www → atlasfinancialsjp.github.io
- TXT _github-pages-challenge-AtlasFinancialsJP

削除後、Workers & Pages → atlas-router → Settings → Domains & Routes → Add Custom domain で `atlas-financials.jp` を設定 → **成功**

### 3.4 ルーターWorkerアーキテクチャ

**課題:** 2つの異なるソース（LP / レポート / ニュース）を同一ドメインの異なるパスで配信する必要がある。

**検討した選択肢:**

| 方式 | メリット | デメリット | 判定 |
|---|---|---|---|
| A. サブドメイン方式 | シンプル | URL全面変更が必要 | ❌ |
| B. 統合リポジトリ方式 | URL維持 | リポジトリ構造の大幅変更 | ❌ |
| C. Workerルーティング方式 | URL維持・独立管理 | Worker経由のレイテンシ微増 | ✅ 採用 |

**最終アーキテクチャ:**
```
atlas-financials.jp (Cloudflare DNS)
        |
   [atlas-router Worker]
        |
        ├── /           → LP（Worker内の静的アセット）
        ├── /reports/*  → Cloudflare Pages「atlas-reports」にプロキシ
        └── /news/*     → Cloudflare Pages「atlas-news」にプロキシ
```

**worker.js のルーティングロジック:**
```javascript
// /reports/* or /news/* → 対応するPages.devにプロキシ
// パスプレフィックスを除去してfetch
const path = url.pathname.replace(/^\/reports/, '') || '/';
const target = new URL(path, 'https://atlas-reports-f0q.pages.dev');
```

### 3.5 音声ファイルの25MB制限対応

**エラー:** `Error: Pages only supports files up to 25 MiB in size`
- `japan-interest-rates-radio.m4a` が 31.7MB

**解決:** m4a → mp3 128kbps に変換
```bash
ffmpeg -i input.m4a -codec:a libmp3lame -b:a 128k output.mp3
```
- 32MB → 17MB に圧縮
- HTML内の `<source>` タグも更新（type="audio/mp4" → type="audio/mpeg"）

**方針:** 今後は音声ファイルは全て mp3 128kbps でデプロイ。30分超の場合はビットレート調整 or 分割。

### 3.6 デプロイスクリプトのCloudflare対応

**deploy_report.py の変更:**
```python
# 旧: git push origin main
# 新: npx wrangler pages deploy {REPO_DIR} --project-name atlas-reports --commit-dirty=true
# git push はバックアップ用にtry-exceptで残す
```

**deploy_times.py の変更:**
```python
# 旧: PAGES_BASE_URL = f"https://{GITHUB_USERNAME}.github.io/{REPO_NAME}"
# 新: PAGES_BASE_URL = "https://atlas-financials.jp/news"
# デプロイ: wrangler pages deploy に変更
```

---

## Phase 4: 最終メンテナンス（2026-04-13）

### 4.1 クリーンアップ実施項目

| # | 対応 | 理由 |
|---|---|---|
| 1 | 旧org CNAME ファイル削除 | DNS衝突リスク解消 |
| 2 | 旧org GitHub Actions workflow 削除 | errored状態で不要 |
| 3 | 空 `.github/workflows/` ディレクトリ削除 | 不要 |
| 4 | `deploy_report.py` 未使用変数削除 | `GITHUB_USERNAME`/`REPO_NAME` は未参照 |
| 5 | `atlas-architecture.md` 全面更新 | 全URLが旧GitHub Pages のままだった |
| 6 | 不要リポジトリ `yskzz121/atlas-landing` 削除 | 回避策で作成したが不要 |

### 4.2 旧URL残存チェック

```bash
grep -r "yskzz121\.github\.io" ~/ui-kabu-reports/deploy_report.py \
  ~/ui-kabu-times/scripts/deploy_times.py ~/atlas-router/worker.js
# → 残存なし ✅
```

---

## 最終状態（2026-04-13）

### 全サービス動作確認

| URL | 状態 |
|---|---|
| `https://atlas-financials.jp/` | **200** ✅ |
| `https://atlas-financials.jp/reports/` | **200** ✅ |
| `https://atlas-financials.jp/reports/NVDA/` | **200** ✅ |
| `https://atlas-financials.jp/news/` | **200** ✅ |
| `https://atlas-financials.jp/news/morning/latest.html` | **200** ✅ |

### 構成図

```
[お名前.com] atlas-financials.jp
      ↓ NS
[Cloudflare] chuck.ns.cloudflare.com / sara.ns.cloudflare.com
      ↓
[atlas-router Worker] ← カスタムドメイン: atlas-financials.jp
      |
      ├── /           → ~/atlas-router/public/ (LP)
      ├── /reports/*  → [atlas-reports Pages] ← ~/ui-kabu-reports/
      └── /news/*     → [atlas-news Pages]    ← ~/ui-kabu-times/
```

### デプロイフロー

```
決算レポート:
  deploy_report.py → wrangler pages deploy → atlas-reports → /reports/*
  
朝刊・号外:
  deploy_times.py → wrangler pages deploy → atlas-news → /news/*

LP更新:
  ~/atlas-router/public/ 編集 → cd ~/atlas-router && npx wrangler deploy
```

---

## 📌 学んだこと・今後の教訓

### GitHub Pages関連
1. **ドメイン検証のVerifyボタン** — 押すたびにコードが再発行される。DNS反映を確認してからVerifyを押す
2. **お名前.comのDNS反映** — 管理画面の「設定完了」は反映完了ではない。`dig` で権威サーバーに直接確認
3. **GitHub Actionsの無効化** — Pages（legacy含む）のビルドも全て停止する
4. **Actionsブロックはアカウントレベル** — 新Orgを作っても解決しない
5. **orgで検証済みドメイン** — 個人アカウントのPagesでは使用不可

### Cloudflare関連
6. **Cloudflare Pages/Workers はGitHub Actionsに依存しない** — 独自ビルドシステムで安定稼働
7. **Pagesの25MB制限** — 音声/動画ファイルは圧縮が必要
8. **DNS自動インポート** — 旧レコードがカスタムドメイン設定をブロックする場合がある。先に削除してから設定
9. **Worker ルーティング** — 複数のPagesプロジェクトを1ドメインで配信する場合に有効
10. **wrangler CLI** — `npx wrangler` でインストール不要。OAuthトークンは24時間で期限切れ

### 運用教訓
11. **GitHub依存のリスク** — 単一サービスへの依存は避け、移行可能な設計にする
12. **サポート対応の遅さ** — セルフサービスで解決できないブロッカーは即座に代替案を検討する
13. **仕様書の重要性** — プロセスを文書化しておけば次回は30分で完了する

---

## 🔗 関連
- [atlas-architecture](atlas-architecture.md) — リポジトリ・URL・VI基盤
- [atlas-launch](atlas-launch.md) — Atlas正式リリース工程
- [Cloudflareドメイン・サービス立ち上げ仕様書](../specs/cloudflare-domain-setup.md) — 今後の新規ドメイン・サービス追加手順
