> For the complete documentation index, see [llms.txt](https://ayakaleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ayakaleaf-pro.ayaka.space/on-premises/ja/she-ding/overleaf-toolkit/tls-proxy.md).

# TLS プロキシ

NGINX を使用して HTTPS 接続を終端するための、任意の TLS プロキシ。

実行 `bin/init --tls` NGINX プロキシ設定でローカル設定を初期化するか、既存のローカル設定に NGINX プロキシ設定を追加するための。A **サンプル** 秘密鍵は次に作成されます `config/nginx/certs/overleaf_key.pem` と **ダミー** 証明書は次に作成されます `config/nginx/certs/overleaf_certificate.pem`。これらを実際の秘密鍵と証明書に置き換えるか、以下の値を設定してください `TLS_PRIVATE_KEY_PATH` と `TLS_CERTIFICATE_PATH` 変数を、それぞれ実際の秘密鍵と証明書のパスに設定してください。

NGINX のデフォルト設定は次に用意されています `config/nginx/nginx.conf` 必要に応じてカスタマイズできます。設定ファイルのパスは次の変数で変更できます `NGINX_CONFIG_PATH` 変数。

{% hint style="success" %}
もしあなたが **docker-compose.yml** ベースのデプロイメントを使っている場合、または独自の NGINX リバースプロキシを管理している場合は、次の例を表示できます **nginx.conf** ファイル [こちら](https://github.com/overleaf/toolkit/blob/master/lib/config-seed/nginx.conf).
{% endhint %}

次のセクションをあなたの `config/overleaf.rc` ファイルに、まだない場合は追加してください:

```
# TLS プロキシ設定（任意）
NGINX_ENABLED=false
NGINX_CONFIG_PATH=config/nginx/nginx.conf
NGINX_HTTP_PORT=80

# これらの IP アドレスをホストの外部 IP アドレスに置き換えてください
NGINX_HTTP_LISTEN_IP=127.0.1.1 
NGINX_TLS_LISTEN_IP=127.0.1.1
TLS_PRIVATE_KEY_PATH=config/nginx/certs/overleaf_key.pem
TLS_CERTIFICATE_PATH=config/nginx/certs/overleaf_certificate.pem
TLS_PORT=443
```

{% hint style="danger" %}
外部 TLS プロキシ（つまり Overleaf Toolkit で管理されていないもの）を使用している場合は、 `OVERLEAF_TRUSTED_PROXY_IPS=loopback,<ip-of-your-tls-proxy>` があなたの `config/variables.env`に設定されていることを確認してください。たとえば `OVERLEAF_TRUSTED_PROXY_IPS=loopback,192.168.13.37`.
{% endhint %}

{% hint style="danger" %}
もし `172.16.0.0/12` （Docker ネットワークのデフォルトサブネット）のサブネットをローカルネットワークに使用している場合は、 `OVERLEAF_TRUSTED_PROXY_IPS=loopback,<network>` あなたの `config/variables.env`。ここで `<network>` は `IPAM -> Config -> Subnet` の `docker inspect overleaf_default`に設定されていることを確認してください。たとえば `OVERLEAF_TRUSTED_PROXY_IPS=loopback,172.19.0.0/16`。これは `X-Forwarded` ヘッダーのなりすましを防ぐためです。
{% endhint %}

{% hint style="info" %}
もし `OVERLEAF_TRUSTED_PROXY_IPS` が手動で設定されていない場合、デフォルトは `loopback`です。手動で設定する場合は、次のいずれかを含める必要があります `loopback`, `localhost` または `127.0.0.1`、これは **nginx** インスタンスを信頼します。これは **sharelatex** コンテナ内で実行されています。
{% endhint %}

信頼済みプロキシ IP を正しく設定していれば、 `/user/sessions` ページでこのように表示されるはずです:

<figure><img src="/files/e7148550d0de3c366f61b5423a9d15ba9fb5bcf6" alt="" width="375"><figcaption></figcaption></figure>

上に表示される IP アドレスがまだ次のようなものである場合 `127.0.0.1` またはプライベート/ローカルネットワークの IP アドレスであれば、信頼済みプロキシの設定、特に `OVERLEAF_TRUSTED_PROXY_IPS`.

プロキシを実行するには、 `NGINX_ENABLED` の `config/overleaf.rc` から `false` へ `true` に変更して、 `bin/up`.

デフォルトでは、HTTPS の Web インターフェースは次の場所で利用できます `https://127.0.1.1:443`。次への接続は `http://127.0.1.1:80` にリダイレクトされます `https://127.0.1.1:443`。NGINX が待ち受ける IP アドレスを変更するには、 `NGINX_HTTP_LISTEN_IP` と `NGINX_TLS_LISTEN_IP` 変数を設定してください。ポートは次の変数で変更できます `NGINX_HTTP_PORT` と `TLS_PORT` 変数。

NGINX の起動に失敗し、エラーメッセージ `Error starting userland proxy: listen tcp4 ... bind: address already in use` が表示される場合は、 `OVERLEAF_LISTEN_IP:OVERLEAF_PORT` が `NGINX_HTTP_LISTEN_IP:NGINX_HTTP_PORT`.

```mermaid
sequenceDiagram
participant user as ユーザー
participant external as 外部ホスト
participant internal as 内部ホスト
participant nginx as nginx
participant sharelatex as sharelatex
participant git-bridge as git-bridge
%% ユーザーが外部ホストに HTTP 接続
user->>+ external: HTTP
note over external: NGINX_HTTP_LISTEN_IP:NGINX_HTTP_PORT
external->>+ nginx: HTTP
note over nginx: nginx:80
nginx-->>-external: 301
%% ユーザーが外部ホストに HTTPS 接続
user->>+ external: HTTPS
note over external: NGINX_TLS_LISTEN_IP:TLS_PORT
external->>+ nginx: HTTPS
note over nginx: nginx:443
nginx->>+ sharelatex: HTTP
note over sharelatex: sharlatex:80
%% ユーザーが localhost に HTTP 接続
user->>+ internal: HTTP
note over internal: OVERLEAF_LISTEN_IP:OVERLEAF_PORT
internal->>+sharelatex: HTTP
note over sharelatex: sharlatex:80
%% sharelatex が git-bridge に接続
sharelatex->>+git-bridge: HTTP /git/
note over git-bridge: git-bridge:8000
note over sharelatex: GIT_BRIDGE_HOST:GIT_BRIDGE_PORT
git-bridge->>+sharelatex: WEB/WEB-API:3000
git-bridge->>+sharelatex: HISTORY-V1:3100
```


---

# 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://ayakaleaf-pro.ayaka.space/on-premises/ja/she-ding/overleaf-toolkit/tls-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.
