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

# Proxy TLS

Opcjonalny proxy TLS do zakończania połączeń HTTPS, używający NGINX.

Uruchom `bin/init --tls` aby zainicjalizować lokalną konfigurację z konfiguracją proxy NGINX lub dodać konfigurację proxy NGINX do istniejącej lokalnej konfiguracji. A **przykładowy** klucz prywatny jest tworzony w `config/nginx/certs/overleaf_key.pem` i **testowy** certyfikat w `config/nginx/certs/overleaf_certificate.pem`. Możesz zastąpić je swoim rzeczywistym kluczem prywatnym i certyfikatem albo ustawić wartości zmiennych `TLS_PRIVATE_KEY_PATH` i `TLS_CERTIFICATE_PATH` na ścieżki do twojego rzeczywistego klucza prywatnego i certyfikatu, odpowiednio.

Domyślna konfiguracja dla NGINX jest dostarczana w `config/nginx/nginx.conf` którą można dostosować do swoich wymagań. Ścieżkę do pliku konfiguracyjnego można zmienić za pomocą `NGINX_CONFIG_PATH` zmiennej.

{% hint style="success" %}
Jeśli masz **docker-compose.yml** wdrożenie oparte na nim albo zarządzasz własnym odwrotnym proxy NGINX, możesz zobaczyć przykładowy **nginx.conf** plik [tutaj](https://github.com/overleaf/toolkit/blob/master/lib/config-seed/nginx.conf).
{% endhint %}

Dodaj następującą sekcję do swojego `config/overleaf.rc` pliku, jeśli jeszcze jej tam nie ma:

```
# Konfiguracja proxy TLS (opcjonalna)
NGINX_ENABLED=false
NGINX_CONFIG_PATH=config/nginx/nginx.conf
NGINX_HTTP_PORT=80

# Zastąp te adresy IP zewnętrznym adresem IP twojego hosta
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" %}
Jeśli używasz zewnętrznego proxy TLS (tj. niezarządzanego przez Overleaf Toolkit), upewnij się, że `OVERLEAF_TRUSTED_PROXY_IPS=loopback,<ip-of-your-tls-proxy>` jest ustawione w twoim `config/variables.env`, np. `OVERLEAF_TRUSTED_PROXY_IPS=loopback,192.168.13.37`.
{% endhint %}

{% hint style="danger" %}
Jeśli używasz podsieci z `172.16.0.0/12` (domyślna podsieć dla sieci Docker) dla swojej sieci lokalnej, będziesz musiał ustawić `OVERLEAF_TRUSTED_PROXY_IPS=loopback,<network>` w swoim `config/variables.env`. Gdzie `<network>` jest `IPAM -> Config -> Subnet` wartością w `docker inspect overleaf_default`, np. `OVERLEAF_TRUSTED_PROXY_IPS=loopback,172.19.0.0/16`. Ma to na celu zapobieganie podszywaniu się pod nagłówki `X-Forwarded` .
{% endhint %}

{% hint style="info" %}
Jeśli `OVERLEAF_TRUSTED_PROXY_IPS` nie jest ustawione ręcznie, domyślnie przyjmuje wartość `loopback`. Jeśli ustawiasz ręcznie, musisz upewnić się, że uwzględniasz jedno z `loopback`, `localhost` lub `127.0.0.1`, co ufa **instancji nginx** uruchomionej wewnątrz **sharelatex** kontenera.
{% endhint %}

Jeśli poprawnie skonfigurowałeś zaufane adresy IP proxy, powinieneś zobaczyć swój publiczny adres IP na `/user/sessions` stronie tak:

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

Jeśli adres IP pokazany powyżej nadal jest czymś w rodzaju `127.0.0.1` lub prywatnym/lokalnym adresem IP sieci, proszę sprawdź konfigurację zaufanego proxy, zwłaszcza wartość `OVERLEAF_TRUSTED_PROXY_IPS`.

Aby uruchomić proxy, zmień wartość `NGINX_ENABLED` zmiennej w `config/overleaf.rc` z `false` na `true` i ponownie uruchom `bin/up`.

Domyślnie interfejs WWW HTTPS będzie dostępny pod adresem `https://127.0.1.1:443`. Połączenia do `http://127.0.1.1:80` będą przekierowywane do `https://127.0.1.1:443`. Aby zmienić adres IP, na którym nasłuchuje NGINX, ustaw `NGINX_HTTP_LISTEN_IP` i `NGINX_TLS_LISTEN_IP` zmienne. Porty można zmienić za pomocą `NGINX_HTTP_PORT` i `TLS_PORT` zmiennych.

Jeśli NGINX nie uruchamia się z komunikatem o błędzie `Error starting userland proxy: listen tcp4 ... bind: address already in use` upewnij się, że `OVERLEAF_LISTEN_IP:OVERLEAF_PORT` nie nakłada się na `NGINX_HTTP_LISTEN_IP:NGINX_HTTP_PORT`.

```mermaid
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
%% Użytkownik łączy się z zewnętrznym hostem 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
%% Użytkownik łączy się z zewnętrznym hostem 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
%% Użytkownik łączy się z localhost przez HTTP
user->>+ internal: HTTP
note over internal: OVERLEAF_LISTEN_IP:OVERLEAF_PORT
internal->>+sharelatex: HTTP
note over sharelatex: sharlatex:80
%% sharelatex łączy się z 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/pl/konfiguracja/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.
