> 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/uk/konfiguraciya/overleaf-toolkit/tls-proxy.md).

# TLS-проксі

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

Виконайте `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 %}

Щоб запустити проксі, змініть значення `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-проксі: 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/uk/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.
