> For the complete documentation index, see [llms.txt](https://help.aikido.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.aikido.dev/docs/docs-ja/sonono/private-registries/on-premise-transparent-proxy.md).

# オンプレミス レジストリプロキシ

## 概要

Aikido On-Prem Registry Proxy は、 **透過的なパッケージファイアウォール**としてデプロイできます。これにより、開発者や CI システムがパッケージマネージャーの設定を変更することなく、組織はパッケージのセキュリティポリシーを適用できます。

クライアントをプライベートレジストリ URL や特別なプロキシパスを使うように設定する代わりに、組織は社内 DNS を使用して、対応する公開パッケージレジストリを Aikido Registry Proxy に転送します。開発者はデフォルトのパッケージマネージャー設定をそのまま使い続け、プロキシは公開レジストリからコンテンツを取得する前に要求を透過的に評価します。

## アーキテクチャ

<figure><img src="/files/7cd54068595772a99f8d00484205539ea7401324" alt=""><figcaption></figcaption></figure>

## プロキシの実行

```bash
docker run -p 8080:8080 -e DEPLOYMENT_MODE=onprem public.ecr.aws/e3k7x4i5/aikido-registry-proxy:latest
```

プロキシはポート `8080` で実行され、TLS は ingress 層で終端されることを想定しています。ingress は元の `Host` ヘッダーを転送する（または `X-Forwarded-Host`を設定する）必要があり、そうすることでプロキシがエコシステムを識別できます。

ヘルスエンドポイントは `GET /health` で利用できます（認証不要）。Kubernetes の liveness / readiness probe に適しています。

## 設定

<table data-search="false"><thead><tr><th>変数</th><th>デフォルト</th><th>説明</th></tr></thead><tbody><tr><td><code>DEPLOYMENT_MODE</code></td><td>デフォルトを上書きして <code>onprem</code></td><td>に設定する必要があります。DNS Proxy のセットアップに必要です</td></tr><tr><td><code>UPSTREAM_DNS</code></td><td><code>1.1.1.1</code></td><td>プロキシ自身の外向き通信に使用される公開 DNS リゾルバー。インターセプトする社内 DNS ではなく、実際の公開リゾルバーを指す必要があります。複数のリゾルバーを指定する場合はカンマ区切りで指定できます。</td></tr><tr><td><code>MINIMUM_PACKAGE_AGE_HOURS</code></td><td><code>48</code></td><td>このしきい値より新しく公開されたパッケージをブロックします。</td></tr><tr><td><code>NPM_UPSTREAM_URL</code></td><td><code>https://registry.npmjs.org</code></td><td>内部の npm ミラーを指すように上書きします。</td></tr><tr><td><code>PYPI_UPSTREAM_URL</code></td><td><code>https://pypi.org</code></td><td>内部の PyPI ミラーを指すように上書きします。</td></tr><tr><td><code>PYPI_FILES_UPSTREAM_URL</code></td><td><code>https://files.pythonhosted.org</code></td><td>内部の PyPI ファイルミラーを指すように上書きします。</td></tr><tr><td><code>MAVEN_UPSTREAM_URL</code></td><td><code>https://repo1.maven.org/maven2</code></td><td>内部の Maven ミラーを指すように上書きします。</td></tr></tbody></table>

## サポートされるホストのマッピング

Registry Proxy は、受信した HTTP Host ヘッダーに基づいて、要求を適切なエコシステムへルーティングします。

| 公開ホスト名                 | エコシステム        |
| ---------------------- | ------------- |
| registry.npmjs.org     | npm           |
| pypi.org               | PyPI          |
| files.pythonhosted.org | PyPI          |
| repo1.maven.org        | Maven Central |

## レジストリ互換性

メタデータの応答では、URL をプロキシパスに書き換えません。クライアントは元の公開レジストリ形式の URL を受け取り、インターセプトされていないホストへリダイレクトされることはありません。

### npm

* Packument の応答は `registry.npmjs.org`.
* tarball のダウンロードは標準の npm ワークフローを使用します。

### PyPI

* メタデータ要求は `pypi.org`.
* パッケージのダウンロードは `files.pythonhosted.org`.

### Maven

* Maven Central への要求は標準の `/maven2/...` パスを使用します。

## 送信元 IP とレート制限

すべてのプロキシトラフィックは 1 つの IP（または 2 つのレプリカがある場合は 2 つの IP）から送信されるため、Maven Central やその他の公開レジストリは、その IP から発生する要求をレート制限したりブロックしたりする可能性があります。これは透過的プロキシモデルの既知の制限です。

これを緩和するには、複数の IP を持つ NAT ゲートウェイ経由で送信トラフィックをルーティングするか、公開レジストリのレート制限を受けない内部ミラーを指すように upstream URL の上書きを設定することを検討してください。

## 上流ルーティングループの防止

プロキシは自身の外向き通信をすべて `UPSTREAM_DNS` リゾルバー（デフォルト `1.1.1.1`）を使用して解決し、コンテナのシステム DNS を完全にバイパスします。つまり、Pod がインターセプトする社内 DNS を継承していても、プロキシの上流フェッチは常に実際の公開レジストリに到達し、ループバックしません。

プロキシホスト自体で split-horizon DNS の設定は不要です。追加の安全策として、Kubernetes の `dnsConfig`.

## 要求フロー

1. 開発者または CI システムが、標準のパッケージマネージャーを使ってパッケージをインストールします。
2. 社内 DNS が公開レジストリのホスト名を内部の Registry Proxy に解決します。
3. Registry Proxy は、元の HTTP Host ヘッダーを使用して要求を受信します。
4. プロキシは、要求されたホスト名に基づいて対象のエコシステムを決定します。
5. マルウェア検出と最小パッケージ経過時間ポリシーが評価されます。
6. 要求が許可されると、プロキシは対応する公開レジストリからパッケージまたはメタデータを取得します。
7. 応答は透過的にクライアントへ返されます。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.aikido.dev/docs/docs-ja/sonono/private-registries/on-premise-transparent-proxy.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
