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

# Proxy TLS

Un proxy TLS opcional para finalizar conexiones HTTPS, utilizando NGINX.

Ejecutar `bin/init --tls` para inicializar la configuración local con la configuración del proxy NGINX, o para añadir la configuración del proxy NGINX a una configuración local existente. Un **ejemplo** clave privada se crea en `config/nginx/certs/overleaf_key.pem` y un **ficticio** certificado en `config/nginx/certs/overleaf_certificate.pem`. Sustitúyelos por tu clave privada y certificado reales, o establece los valores de las `TLS_PRIVATE_KEY_PATH` y `TLS_CERTIFICATE_PATH` variables a las rutas de tu clave privada y certificado reales, respectivamente.

Se proporciona una configuración predeterminada para NGINX en `config/nginx/nginx.conf` que puede personalizarse según tus necesidades. La ruta al archivo de configuración puede cambiarse con la `NGINX_CONFIG_PATH` variable.

{% hint style="success" %}
Si tienes un **docker-compose.yml** despliegue basado en, o administras tu propio proxy inverso NGINX, puedes ver un ejemplo **nginx.conf** archivo [aquí](https://github.com/overleaf/toolkit/blob/master/lib/config-seed/nginx.conf).
{% endhint %}

Añade la siguiente sección a tu `config/overleaf.rc` archivo si aún no está allí:

```
# Configuración del proxy TLS (opcional)
NGINX_ENABLED=false
NGINX_CONFIG_PATH=config/nginx/nginx.conf
NGINX_HTTP_PORT=80

# Reemplaza estas direcciones IP con la dirección IP externa de tu 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" %}
Si estás usando un proxy TLS externo (es decir, no administrado por Overleaf Toolkit), asegúrate de que `OVERLEAF_TRUSTED_PROXY_IPS=loopback,<ip-of-your-tls-proxy>` esté establecido en tu `config/variables.env`, por ejemplo `OVERLEAF_TRUSTED_PROXY_IPS=loopback,192.168.13.37`.
{% endhint %}

{% hint style="danger" %}
Si estás usando una subred de `172.16.0.0/12` (subred predeterminada para redes de Docker) para tu red local, tendrás que establecer `OVERLEAF_TRUSTED_PROXY_IPS=loopback,<network>` en tu `config/variables.env`. Donde `<network>` es el `IPAM -> Config -> Subnet` valor en `docker inspect overleaf_default`, por ejemplo `OVERLEAF_TRUSTED_PROXY_IPS=loopback,172.19.0.0/16`. Esto es para evitar la suplantación de `X-Forwarded` encabezados.
{% endhint %}

{% hint style="info" %}
Si `OVERLEAF_TRUSTED_PROXY_IPS` no se establece manualmente, por defecto es `loopback`. Si lo estableces manualmente, debes asegurarte de incluir uno de `loopback`, `localhost` o `127.0.0.1`, que confía en la instancia de **nginx** que se ejecuta dentro del contenedor **sharelatex** .
{% endhint %}

Si has configurado correctamente las IP de proxy de confianza, deberías ver tu dirección IP pública en la `/user/sessions` página como esta:

<figure><img src="/files/72c5cf0639b37fb08b94be317067c3d0ff4b9de4" alt="" width="375"><figcaption></figcaption></figure>

Si la dirección IP mostrada arriba sigue siendo algo como `127.0.0.1` o una dirección IP de red privada/local, revisa tu configuración de proxy de confianza, especialmente el valor de `OVERLEAF_TRUSTED_PROXY_IPS`.

Para ejecutar el proxy, cambia el valor de la `NGINX_ENABLED` variable en `config/overleaf.rc` de `false` a `true` y vuelve a ejecutar `bin/up`.

Por defecto, la interfaz web HTTPS estará disponible en `https://127.0.1.1:443`. Las conexiones a `http://127.0.1.1:80` serán redirigidas a `https://127.0.1.1:443`. Para cambiar la dirección IP en la que escucha NGINX, establece las `NGINX_HTTP_LISTEN_IP` y `NGINX_TLS_LISTEN_IP` variables. Los puertos pueden cambiarse mediante las `NGINX_HTTP_PORT` y `TLS_PORT` variables.

Si NGINX no puede iniciarse con el mensaje de error `Error starting userland proxy: listen tcp4 ... bind: address already in use` asegúrate de que `OVERLEAF_LISTEN_IP:OVERLEAF_PORT` no se solape con `NGINX_HTTP_LISTEN_IP:NGINX_HTTP_PORT`.

```mermaid
sequenceDiagram
participant user as Usuario
participant external as Host externo
participant internal as Host interno
participant nginx as nginx
participant sharelatex as sharelatex
participant git-bridge as git-bridge
%% El usuario se conecta al HTTP del host externo
user->>+ external: HTTP
note over external: NGINX_HTTP_LISTEN_IP:NGINX_HTTP_PORT
external->>+ nginx: HTTP
note over nginx: nginx:80
nginx-->>-external: 301
%% El usuario se conecta al HTTPS del host externo
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
%% El usuario se conecta al HTTP de localhost
user->>+ internal: HTTP
note over internal: OVERLEAF_LISTEN_IP:OVERLEAF_PORT
internal->>+sharelatex: HTTP
note over sharelatex: sharlatex:80
%% sharelatex se conecta a 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/es/configuracion/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.
