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

# Proxy TLS

Un proxy TLS optionnel pour terminer les connexions HTTPS, utilisant NGINX.

Exécutez `bin/init --tls` pour initialiser la configuration locale avec la configuration du proxy NGINX, ou pour ajouter la configuration du proxy NGINX à une configuration locale existante. Un **exemple** clé privée est créée dans `config/nginx/certs/overleaf_key.pem` et un **factice** certificat dans `config/nginx/certs/overleaf_certificate.pem`. Remplacez-les soit par votre clé privée et votre certificat réels, soit définissez les valeurs de `TLS_PRIVATE_KEY_PATH` et `TLS_CERTIFICATE_PATH` sur les chemins de votre clé privée et de votre certificat réels respectivement.

Une configuration par défaut pour NGINX est fournie dans `config/nginx/nginx.conf` qui peut être personnalisée selon vos besoins. Le chemin du fichier de configuration peut être modifié avec la `NGINX_CONFIG_PATH` variable.

{% hint style="success" %}
Si vous avez un **docker-compose.yml** basé sur un déploiement, ou gérez votre propre proxy inverse NGINX, vous pouvez consulter un exemple **nginx.conf** fichier [ici](https://github.com/overleaf/toolkit/blob/master/lib/config-seed/nginx.conf).
{% endhint %}

Ajoutez la section suivante à votre `config/overleaf.rc` fichier si elle n’y est pas déjà :

```
# Configuration du proxy TLS (facultatif)
NGINX_ENABLED=false
NGINX_CONFIG_PATH=config/nginx/nginx.conf
NGINX_HTTP_PORT=80

# Remplacez ces adresses IP par l'adresse IP externe de votre hôte
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" %}
Si vous utilisez un proxy TLS externe (c.-à-d. non géré par l’Overleaf Toolkit), veuillez vous assurer que `OVERLEAF_TRUSTED_PROXY_IPS=loopback,<ip-of-your-tls-proxy>` est défini dans votre `config/variables.env`, par exemple `OVERLEAF_TRUSTED_PROXY_IPS=loopback,192.168.13.37`.
{% endhint %}

{% hint style="danger" %}
Si vous utilisez un sous-réseau de `172.16.0.0/12` (sous-réseau par défaut pour les réseaux Docker) pour votre réseau local, vous devrez définir `OVERLEAF_TRUSTED_PROXY_IPS=loopback,<network>` dans votre `config/variables.env`. `<network>` est la `IPAM -> Config -> Subnet` valeur dans `docker inspect overleaf_default`, par exemple `OVERLEAF_TRUSTED_PROXY_IPS=loopback,172.19.0.0/16`. Ceci afin d'empêcher l'usurpation des `X-Forwarded` en-têtes.
{% endhint %}

{% hint style="info" %}
Si `OVERLEAF_TRUSTED_PROXY_IPS` n'est pas défini manuellement, il prend par défaut la valeur `loopback`. Si vous le définissez manuellement, vous devez vous assurer d'inclure l'un de `loopback`, `localhost` ou `127.0.0.1`, qui fait confiance à l'instance **nginx** en cours d'exécution dans le conteneur **sharelatex** .
{% endhint %}

Si vous avez configuré correctement les IP des proxys de confiance, vous devriez voir votre adresse IP publique sur la page `/user/sessions` comme ceci :

<figure><img src="/files/85712ba4ff6dadd8251332983645f061fd45e112" alt="" width="375"><figcaption></figcaption></figure>

Si l'adresse IP affichée ci-dessus est toujours quelque chose comme `127.0.0.1` ou une adresse IP de réseau privé/local, veuillez vérifier votre configuration de proxy de confiance, en particulier la valeur de `OVERLEAF_TRUSTED_PROXY_IPS`.

Afin d'exécuter le proxy, modifiez la valeur de `NGINX_ENABLED` variable dans `config/overleaf.rc` de `false` à `true` et relancez `bin/up`.

Par défaut, l'interface web HTTPS sera disponible sur `https://127.0.1.1:443`. Les connexions à `http://127.0.1.1:80` seront redirigées vers `https://127.0.1.1:443`. Pour changer l'adresse IP sur laquelle NGINX écoute, définissez les `NGINX_HTTP_LISTEN_IP` et `NGINX_TLS_LISTEN_IP` variables. Les ports peuvent être modifiés via les `NGINX_HTTP_PORT` et `TLS_PORT` variables.

Si NGINX ne parvient pas à démarrer avec le message d'erreur `Error starting userland proxy: listen tcp4 ... bind: address already in use` assurez-vous que `OVERLEAF_LISTEN_IP:OVERLEAF_PORT` ne chevauche pas `NGINX_HTTP_LISTEN_IP:NGINX_HTTP_PORT`.

```mermaid
sequenceDiagram
participant user as Utilisateur
participant external as Hôte externe
participant internal as Hôte interne
participant nginx as nginx
participant sharelatex as sharelatex
participant git-bridge as git-bridge
%% L'utilisateur se connecte à l'hôte externe en 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
%% L'utilisateur se connecte à l'hôte externe en 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
%% L'utilisateur se connecte à localhost en HTTP
user->>+ internal: HTTP
note over internal: OVERLEAF_LISTEN_IP:OVERLEAF_PORT
internal->>+sharelatex: HTTP
note over sharelatex: sharlatex:80
%% sharelatex se connecte à 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/fr/configuration/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.
