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

# TLS-välityspalvelin

Valinnainen TLS-välityspalvelin HTTPS-yhteyksien päättämiseen NGINX:ää käyttäen.

Suorita `bin/init --tls` alustamaan paikallisen kokoonpanon NGINX-välityspalvelinkokoonpanolla tai lisäämään NGINX-välityspalvelinkokoonpanon olemassa olevaan paikalliseen kokoonpanoon. A **esimerkki** yksityinen avain luodaan tiedostoon `config/nginx/certs/overleaf_key.pem` ja yksi **testi** varmenne tiedostossa `config/nginx/certs/overleaf_certificate.pem`. Korvaa nämä joko varsinaisella yksityisellä avaimellasi ja varmenteellasi tai aseta arvot `TLS_PRIVATE_KEY_PATH` ja `TLS_CERTIFICATE_PATH` muuttujiin oman varsinaisen yksityisen avaimesi ja varmenteesi polut vastaavasti.

NGINXin oletuskokoonpano on tarjolla tiedostossa `config/nginx/nginx.conf` jota voidaan mukauttaa tarpeidesi mukaan. Konfiguraatiotiedoston polkua voidaan muuttaa `NGINX_CONFIG_PATH` muuttujalla.

{% hint style="success" %}
Jos sinulla on **docker-compose.yml** pohjainen käyttöönotto tai hallinnoit omaa NGINX-käänteisvälityspalvelintasi, voit tarkastella esimerkkiä **nginx.conf** tiedosto [tässä](https://github.com/overleaf/toolkit/blob/master/lib/config-seed/nginx.conf).
{% endhint %}

Lisää seuraava osio omaan `config/overleaf.rc` tiedostoosi, jos sitä ei ole siellä jo:

```
# TLS-välityspalvelimen kokoonpano (valinnainen)
NGINX_ENABLED=false
NGINX_CONFIG_PATH=config/nginx/nginx.conf
NGINX_HTTP_PORT=80

# Korvaa nämä IP-osoitteet isäntäkoneesi ulkoisella IP-osoitteella
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" %}
Jos käytät ulkoista TLS-välityspalvelinta (eli sellaista, jota Overleaf Toolkit ei hallinnoi), varmista että `OVERLEAF_TRUSTED_PROXY_IPS=loopback,<ip-of-your-tls-proxy>` on asetettu sinun `config/variables.env`, esim. `OVERLEAF_TRUSTED_PROXY_IPS=loopback,192.168.13.37`.
{% endhint %}

{% hint style="danger" %}
Jos käytät aliverkkoa osoitteesta `172.16.0.0/12` (Docker-verkkojen oletusaliverkko) paikallisessa verkossasi, sinun on asetettava `OVERLEAF_TRUSTED_PROXY_IPS=loopback,<network>` tiedostoosi `config/variables.env`. Missä `<network>` on `IPAM -> Config -> Subnet` arvo kohdassa `docker inspect overleaf_default`, esim. `OVERLEAF_TRUSTED_PROXY_IPS=loopback,172.19.0.0/16`. Tämän tarkoituksena on estää `X-Forwarded` otsikot.
{% endhint %}

{% hint style="info" %}
Jos `OVERLEAF_TRUSTED_PROXY_IPS` ei aseteta manuaalisesti, oletusarvo on `loopback`. Jos asetat sen manuaalisesti, sinun on varmistettava, että sisällytät yhden seuraavista `loopback`, `localhost` tai `127.0.0.1`, joka luottaa **nginx** säilön sisällä käynnissä olevaan instanssiin **sharelatex** säilön sisällä.
{% endhint %}

Jotta välityspalvelin voidaan käynnistää, muuta arvon `NGINX_ENABLED` muuttujalla tiedostossa `config/overleaf.rc` lähettäjä `false` versioon `true` ja suorita uudelleen `bin/up`.

Oletusarvoisesti HTTPS-verkkokäyttöliittymä on käytettävissä osoitteessa `https://127.0.1.1:443`. Yhteydet osoitteeseen `http://127.0.1.1:80` uudelleenohjataan osoitteeseen `https://127.0.1.1:443`. Jos haluat muuttaa IP-osoitetta, johon NGINX kuuntelee, aseta `NGINX_HTTP_LISTEN_IP` ja `NGINX_TLS_LISTEN_IP` muuttujat. Portteja voidaan muuttaa `NGINX_HTTP_PORT` ja `TLS_PORT` muuttujien avulla.

Jos NGINX ei käynnisty virheilmoituksella `Error starting userland proxy: listen tcp4 ... bind: address already in use` varmista, että `OVERLEAF_LISTEN_IP:OVERLEAF_PORT` ei mene päällekkäin `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/fi/maaritys/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.
