> For the complete documentation index, see [llms.txt](https://overleaf-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://overleaf-pro.ayaka.space/on-premises/ru/konfiguraciya/overleaf-toolkit/tls-proxy.md).

# TLS-прокси

Необязательный TLS-прокси для завершения HTTPS-соединений с использованием NGINX.

Выполните `bin/init --tls` для инициализации локальной конфигурации с конфигурацией прокси NGINX или для добавления конфигурации прокси NGINX к существующей локальной конфигурации. А **пример** закрытый ключ создается в `config/nginx/certs/overleaf_key.pem` и **фиктивный** сертификат в `config/nginx/certs/overleaf_certificate.pem`. Либо замените их на свой действительный закрытый ключ и сертификат, либо задайте значения `TLS_PRIVATE_KEY_PATH` и `TLS_CERTIFICATE_PATH` соответственно, на пути к вашему действительному закрытому ключу и сертификату.

Конфигурация NGINX по умолчанию предоставляется в `config/nginx/nginx.conf` которую можно настроить под ваши требования. Путь к файлу конфигурации можно изменить с помощью `переменной` переменной.

{% 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 %}

Чтобы запустить прокси, измените значение `NGINX_ENABLED` переменной в `config/overleaf.rc` адрес «От» `false` с `true` и запустите снова `bin/up`.

По умолчанию веб-интерфейс HTTPS будет доступен по адресу `https://127.0.1.1:443`. Подключения к `http://127.0.1.1:80` будут перенаправляться на `https://127.0.1.1:443`. Чтобы изменить IP-адрес, на котором NGINX слушает, задайте `NGINX_HTTP_LISTEN_IP` и `NGINX_TLS_LISTEN_IP` переменные. Порты можно изменить через `NGINX_HTTP_PORT` и `TLS_PORT` переменные.

Если NGINX не удается запустить с сообщением об ошибке `Ошибка запуска userland proxy: listen tcp4 ... bind: адрес уже используется` убедитесь, что `OVERLEAF_LISTEN_IP:OVERLEAF_PORT` не пересекается с `NGINX_HTTP_LISTEN_IP:NGINX_HTTP_PORT`.

{% @mermaid/diagram content="sequenceDiagram
participant user as User
participant external as Host External
participant internal as Host Internal
participant nginx as nginx
participant sharelatex as sharelatex
participant git-bridge as git-bridge
%% User connects to external host 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
%% User connects to external host 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
%% User connects to localhost HTTP
user->>+ internal: HTTP
note over internal: OVERLEAF\_LISTEN\_IP:OVERLEAF\_PORT
internal->>+sharelatex: HTTP
note over sharelatex: sharlatex:80
%% sharelatex connects to 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://overleaf-pro.ayaka.space/on-premises/ru/konfiguraciya/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.
