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

# Proksi TLS

Proxy TLS opsional untuk mengakhiri koneksi HTTPS, menggunakan NGINX.

Jalankan `bin/init --tls` untuk menginisialisasi konfigurasi lokal dengan konfigurasi proxy NGINX, atau untuk menambahkan konfigurasi proxy NGINX ke konfigurasi lokal yang sudah ada. Sebuah **contoh** kunci privat dibuat di `config/nginx/certs/overleaf_key.pem` dan sebuah **dummy** sertifikat di `config/nginx/certs/overleaf_certificate.pem`. Atau ganti ini dengan kunci privat dan sertifikat Anda yang sebenarnya, atau atur nilai dari `TLS_PRIVATE_KEY_PATH` dan `TLS_CERTIFICATE_PATH` variabel ke jalur kunci privat dan sertifikat Anda yang sebenarnya masing-masing.

Konfigurasi default untuk NGINX disediakan di `config/nginx/nginx.conf` yang dapat disesuaikan dengan kebutuhan Anda. Jalur ke berkas konfigurasi dapat diubah dengan `NGINX_CONFIG_PATH` variabel.

{% hint style="success" %}
Jika Anda memiliki **docker-compose.yml** berbasis deployment, atau mengelola reverse proxy NGINX Anda sendiri, Anda dapat melihat contoh **nginx.conf** berkas [di sini](https://github.com/overleaf/toolkit/blob/master/lib/config-seed/nginx.conf).
{% endhint %}

Tambahkan bagian berikut ke `berkas config/overleaf.rc` Anda jika belum ada:

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

# Ganti alamat IP ini dengan alamat IP eksternal host Anda
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" %}
Jika Anda menggunakan proxy TLS eksternal (yaitu tidak dikelola oleh Overleaf Toolkit), pastikan bahwa `OVERLEAF_TRUSTED_PROXY_IPS=loopback,<ip-of-your-tls-proxy>` diatur dalam `config/variables.env`, misalnya `OVERLEAF_TRUSTED_PROXY_IPS=loopback,192.168.13.37`.
{% endhint %}

{% hint style="danger" %}
Jika Anda menggunakan subnet dari `172.16.0.0/12` (subnet default untuk jaringan Docker) untuk jaringan lokal Anda, Anda perlu mengatur `OVERLEAF_TRUSTED_PROXY_IPS=loopback,<network>` di `config/variables.env`. Di mana `<network>` adalah `IPAM -> Config -> Subnet` nilai dalam `docker inspect overleaf_default`, misalnya `OVERLEAF_TRUSTED_PROXY_IPS=loopback,172.19.0.0/16`. Ini untuk mencegah pemalsuan `X-Forwarded` header.
{% endhint %}

{% hint style="info" %}
Jika `OVERLEAF_TRUSTED_PROXY_IPS` tidak diatur secara manual, nilainya secara default adalah `loopback`. Jika diatur manual, Anda harus memastikan bahwa Anda menyertakan salah satu dari `loopback`, `localhost` atau `127.0.0.1`, yang mempercayai **nginx** instance yang berjalan di dalam **sharelatex** container.
{% endhint %}

Jika Anda telah mengonfigurasi IP proxy tepercaya dengan benar, Anda seharusnya melihat alamat IP publik Anda pada halaman `/user/sessions` seperti ini:

<figure><img src="/files/8692acf7c75d5cf9e8d8b19adcbb4a08abff6a26" alt="" width="375"><figcaption></figcaption></figure>

Jika alamat IP yang ditampilkan di atas masih sesuatu seperti `127.0.0.1` atau alamat IP jaringan pribadi/lokal, silakan periksa konfigurasi proxy tepercaya Anda, terutama nilai dari `OVERLEAF_TRUSTED_PROXY_IPS`.

Untuk menjalankan proxy, ubah nilai dari `NGINX_ENABLED` variabel di `berkas config/overleaf.rc` dari `false` menjadi `true` dan jalankan ulang `bin/up`.

Secara default, antarmuka web HTTPS akan tersedia di `https://127.0.1.1:443`. Koneksi ke `http://127.0.1.1:80` akan dialihkan ke `https://127.0.1.1:443`. Untuk mengubah alamat IP tempat NGINX mendengarkan, atur `NGINX_HTTP_LISTEN_IP` dan `NGINX_TLS_LISTEN_IP` variabel. Port dapat diubah melalui `NGINX_HTTP_PORT` dan `TLS_PORT` variabel.

Jika NGINX gagal dimulai dengan pesan error `Error starting userland proxy: listen tcp4 ... bind: address already in use` pastikan bahwa `OVERLEAF_LISTEN_IP:OVERLEAF_PORT` tidak tumpang tindih dengan `NGINX_HTTP_LISTEN_IP:NGINX_HTTP_PORT`.

```mermaid
sequenceDiagram
participant user as Pengguna
participant external as Host Eksternal
participant internal as Host Internal
participant nginx as nginx
participant sharelatex as sharelatex
participant git-bridge as git-bridge
%% Pengguna terhubung ke HTTP host eksternal
user->>+ external: HTTP
note over external: NGINX_HTTP_LISTEN_IP:NGINX_HTTP_PORT
external->>+ nginx: HTTP
note over nginx: nginx:80
nginx-->>-external: 301
%% Pengguna terhubung ke HTTPS host eksternal
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
%% Pengguna terhubung ke localhost HTTP
user->>+ internal: HTTP
note over internal: OVERLEAF_LISTEN_IP:OVERLEAF_PORT
internal->>+sharelatex: HTTP
note over sharelatex: sharlatex:80
%% sharelatex terhubung ke 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/id/konfigurasi/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.
