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

# وكيل TLS

وكيل TLS اختياري لإنهاء اتصالات HTTPS، باستخدام NGINX.

شغّل `bin/init --tls` لتهيئة الإعدادات المحلية باستخدام إعداد وكيل NGINX، أو لإضافة إعداد وكيل NGINX إلى إعداد محلي موجود. أ **مثال** يتم إنشاء مفتاح خاص في `config/nginx/certs/overleaf_key.pem` و **وهمي** شهادة في `config/nginx/certs/overleaf_certificate.pem`. إمّا استبدل هذه بالمفتاح الخاص والشهادة الفعليين، أو اضبط قيم `TLS_PRIVATE_KEY_PATH` و `TLS_CERTIFICATE_PATH` على مسارات مفتاحك الخاص الفعلي وشهادتك الفعلية على الترتيب.

توجد إعدادات افتراضية لـ NGINX في `config/nginx/nginx.conf` والتي يمكن تخصيصها وفقًا لاحتياجاتك. يمكن تغيير مسار ملف الإعدادات باستخدام `NGINX_CONFIG_PATH` المتغيّر.

{% hint style="success" %}
إذا كان لديك **docker-compose.yml** نشر يعتمد على، أو تدير وكيل NGINX العكسي الخاص بك، يمكنك عرض مثال **nginx.conf** ملف [هنا](https://github.com/overleaf/toolkit/blob/master/lib/config-seed/nginx.conf).
{% endhint %}

أضف القسم التالي إلى `config/overleaf.rc` الملف إذا لم يكن موجودًا بالفعل:

```
# إعداد وكيل TLS (اختياري)
NGINX_ENABLED=false
NGINX_CONFIG_PATH=config/nginx/nginx.conf
NGINX_HTTP_PORT=80

# استبدل عناوين IP هذه بعنوان IP الخارجي للمضيف
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" %}
إذا كنت تستخدم وكيل TLS خارجيًا (أي ليس مُدارًا بواسطة Overleaf Toolkit)، فيرجى التأكد من أن `OVERLEAF_TRUSTED_PROXY_IPS=loopback,<ip-of-your-tls-proxy>` مُعيَّن في `config/variables.env`، على سبيل المثال `OVERLEAF_TRUSTED_PROXY_IPS=loopback,192.168.13.37`.
{% endhint %}

{% hint style="danger" %}
إذا كنت تستخدم شبكة فرعية من `172.16.0.0/12` (الشبكة الفرعية الافتراضية لشبكات Docker) لشبكتك المحلية، فستحتاج إلى تعيين `OVERLEAF_TRUSTED_PROXY_IPS=loopback,<network>` في `config/variables.env`. حيث `<network>` هو `IPAM -> Config -> Subnet` قيمة في `docker inspect overleaf_default`، على سبيل المثال `OVERLEAF_TRUSTED_PROXY_IPS=loopback,172.19.0.0/16`. وذلك لمنع انتحال `X-Forwarded` رؤوس.
{% endhint %}

{% hint style="info" %}
إذا كان `OVERLEAF_TRUSTED_PROXY_IPS` غير مُعيَّن يدويًا، فستكون القيمة الافتراضية له `loopback`. إذا تم التعيين يدويًا، فيجب التأكد من تضمين أحد `loopback`, `localhost` أو `127.0.0.1`، والذي يثق في **nginx** المثيل الذي يعمل داخل **sharelatex** الحاوية.
{% endhint %}

إذا قمت بتكوين عناوين IP للوكيل الموثوق بشكل صحيح، فيجب أن ترى عنوان IP العام الخاص بك على `/user/sessions` الصفحة هكذا:

<figure><img src="/files/00afd0839f0b39b0f096d4c55812ca6d651bd577" alt="" width="375"><figcaption></figcaption></figure>

إذا كان عنوان IP المعروض أعلاه لا يزال شيئًا مثل `127.0.0.1` أو عنوان IP لشبكة خاصة/محلية، فيرجى التحقق من إعدادات الوكيل الموثوق، وخاصة قيمة `OVERLEAF_TRUSTED_PROXY_IPS`.

لتشغيل الوكيل، غيّر قيمة `NGINX_ENABLED` المتغيّر في `config/overleaf.rc` من `false` إلى `true` وأعد تشغيل `bin/up`.

افتراضيًا، ستكون واجهة الويب عبر HTTPS متاحة على `https://127.0.1.1:443`. سيتم إعادة توجيه الاتصالات إلى `http://127.0.1.1:80` إلى `https://127.0.1.1:443`. لتغيير عنوان IP الذي يستمع عليه NGINX، اضبط `NGINX_HTTP_LISTEN_IP` و `NGINX_TLS_LISTEN_IP` المتغيّرات. يمكن تغيير المنافذ عبر `NGINX_HTTP_PORT` و `TLS_PORT` المتغيّرات.

إذا فشل NGINX في البدء مع رسالة الخطأ `خطأ بدء وكيل userland: listen tcp4 ... bind: العنوان مستخدم بالفعل` تأكد من أن `OVERLEAF_LISTEN_IP:OVERLEAF_PORT` لا يتداخل مع `NGINX_HTTP_LISTEN_IP:NGINX_HTTP_PORT`.

```mermaid
sequenceDiagram
participant user as المستخدم
participant external as المضيف الخارجي
participant internal as المضيف الداخلي
participant nginx as nginx
participant sharelatex as sharelatex
participant git-bridge as git-bridge
%% يتصل المستخدم بالمضيف الخارجي عبر 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
%% يتصل المستخدم بالمضيف الخارجي عبر 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
%% يتصل المستخدم بـ localhost عبر HTTP
user->>+ internal: HTTP
note over internal: OVERLEAF_LISTEN_IP:OVERLEAF_PORT
internal->>+sharelatex: HTTP
note over sharelatex: sharlatex:80
%% يتصل sharelatex بـ 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/ar/althyeh/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.
