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

# Proxy TLS

Un proxy TLS opzionale per terminare le connessioni HTTPS, utilizzando NGINX.

Esegui `bin/init --tls` per inizializzare la configurazione locale con la configurazione del proxy NGINX, oppure per aggiungere la configurazione del proxy NGINX a una configurazione locale esistente. Un **esempio** la chiave privata viene creata in `config/nginx/certs/overleaf_key.pem` e un **fittizio** certificato in `config/nginx/certs/overleaf_certificate.pem`. In alternativa, sostituisci questi con la tua chiave privata e il tuo certificato reali, oppure imposta i valori di `TLS_PRIVATE_KEY_PATH` e `TLS_CERTIFICATE_PATH` ai rispettivi percorsi della tua chiave privata e del tuo certificato reali.

Una configurazione predefinita per NGINX è fornita in `config/nginx/nginx.conf` che può essere personalizzata in base alle tue esigenze. Il percorso del file di configurazione può essere modificato con la `NGINX_CONFIG_PATH` variabile.

{% hint style="success" %}
Se hai una **docker-compose.yml** basata su una distribuzione, oppure gestisci il tuo reverse proxy NGINX, puoi visualizzare un esempio **nginx.conf** file [qui](https://github.com/overleaf/toolkit/blob/master/lib/config-seed/nginx.conf).
{% endhint %}

Aggiungi la seguente sezione al tuo `config/overleaf.rc` file se non è già presente:

```
# Configurazione del proxy TLS (opzionale)
NGINX_ENABLED=false
NGINX_CONFIG_PATH=config/nginx/nginx.conf
NGINX_HTTP_PORT=80

# Sostituisci questi indirizzi IP con l'indirizzo IP esterno del tuo host
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" %}
Se stai utilizzando un proxy TLS esterno (cioè non gestito dall'Overleaf Toolkit), assicurati che `OVERLEAF_TRUSTED_PROXY_IPS=loopback,<ip-of-your-tls-proxy>` sia impostato nel tuo `config/variables.env`, ad esempio `OVERLEAF_TRUSTED_PROXY_IPS=loopback,192.168.13.37`.
{% endhint %}

{% hint style="danger" %}
Se stai utilizzando una subnet da `172.16.0.0/12` (subnet predefinita per le reti Docker) per la tua rete locale, dovrai impostare `OVERLEAF_TRUSTED_PROXY_IPS=loopback,<network>` nel tuo `config/variables.env`. Dove `<network>` è il `IPAM -> Config -> Subnet` valore in `docker inspect overleaf_default`, ad esempio `OVERLEAF_TRUSTED_PROXY_IPS=loopback,172.19.0.0/16`. Questo serve a impedire la falsificazione degli `X-Forwarded` intestazioni.
{% endhint %}

{% hint style="info" %}
Se il `OVERLEAF_TRUSTED_PROXY_IPS` non è impostato manualmente, per impostazione predefinita è `loopback`. Se lo imposti manualmente, devi assicurarti di includere uno di `loopback`, `localhost` o `127.0.0.1`, che si fida dell' **nginx** istanza in esecuzione all'interno del **sharelatex** contenitore.
{% endhint %}

Per eseguire il proxy, cambia il valore di `NGINX_ENABLED` variabile in `config/overleaf.rc` mittente `false` a `true` e riesegui `bin/up`.

Per impostazione predefinita, l'interfaccia web HTTPS sarà disponibile su `https://127.0.1.1:443`. Le connessioni a `http://127.0.1.1:80` verranno reindirizzate a `https://127.0.1.1:443`. Per cambiare l'indirizzo IP su cui NGINX è in ascolto, imposta le `NGINX_HTTP_LISTEN_IP` e `NGINX_TLS_LISTEN_IP` variabili. Le porte possono essere cambiate tramite le `NGINX_HTTP_PORT` e `TLS_PORT` variabili.

Se NGINX non riesce ad avviarsi con il messaggio di errore `Errore nell'avvio del proxy userland: listen tcp4 ... bind: indirizzo già in uso` assicurati che `OVERLEAF_LISTEN_IP:OVERLEAF_PORT` non si sovrapponga a `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/it/configurazione/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.
